Cet article explique comment extraire un Backup WP Staging en ligne de commande à l’aide de l’outil wpstaging cli. Si tu rencontres des difficultés avec la ligne de commande, tu peux utiliser un autre outil nommé WP Staging restore tool pour faire le même travail avec une interface graphique.
wpstaging cli est un outil puissant en ligne de commande haute performance conçu pour traiter les fichiers de Backup WP Staging depuis la ligne de commande sur chaque système d’exploitation majeur.
Avec cet outil, les utilisateurs peuvent extraire, normaliser et inspecter le contenu des fichiers de Backup .wpstg créés par le Plugin WP Staging. Cet extracteur autonome est programmé en Go, garantissant une vitesse et une efficacité exceptionnelles, et fonctionne indépendamment de WordPress.
L’outil en ligne de commande `wp-staging-cli` fait partie des plans WP Staging Developer et Agency et peut être téléchargé depuis GitHub.
Contents
Fonctionnalités clés
- Extraction des fichiers de Backup et de la base de données : accède à tout le contenu des fichiers de Backup
.wpstg. - Normalisation de la base de données : normalise les fichiers de base de données dans le Backup.
- Extraction des métadonnées : extrait et affiche les métadonnées du fichier de Backup.
- Extraction d’index et d’en-tête : récupère les informations d’index et d’en-tête du fichier de Backup.
Référence de performance
wp-staging-cli est exceptionnellement rapide. Par exemple, il peut extraire un Backup de 20 Go en moins de 36 secondes sur un AMD Ryzen™ 7 PRO 7840U avec un SSD rapide sous Ubuntu 22.04.
Installation
Étape 1 : télécharger les exécutables
- Télécharge les fichiers exécutables pour Windows, Linux et Mac OS depuis ici.
- Extrais le fichier zip et sélectionne le binaire approprié pour ton système d’exploitation dans le dossier
build. - (Facultatif) Déplace le binaire
wp-staging-clivers un répertoire dans tonPATHpour un accès facile. Par exemple, sous Linux :
mv wp-staging-cli /usr/local/bin/Instructions d’utilisation
Pour exécuter wp-staging-cli, utilise la commande suivante :
wp-staging-cli [options] <backupfile.wpstg>Arguments
<backupfile.wpstg>: chemin vers le fichier de Backup WP Staging à traiter. Cet argument est obligatoire.
Les options et arguments de commande peuvent être utilisés dans n’importe quel ordre.
- Les options peuvent avoir un préfixe de tiret simple ‘-‘ ou double ‘–‘.
- Les options avec des valeurs peuvent être définies avec ou sans ‘=’.
Options
Commands:
extract - Extract items from the backup. Default if no command is specified.
restore - Restore the backup file.
help - Display all help message.
Arguments:
backupfile.wpstg - Path to the WP Staging backup file that will be processed. This argument is mandatory.
General Options:
-l, --license=<licensekey> - WP Staging Pro License Key. Required to access the backup file.
Alternatively, use the `WPSTGPRO_LICENSE` environment variable.
-o, --outputdir=<path> - Specify the extraction directory path where processed files will be stored. Default: "./wp-staging-cli-output".
-n, --normalizedb - Normalize database files during the `extract` process.
This will replace all WP Staging specific placeholders and allows the sql file to be imported by
any regular db admin tool.
--workingdir=<path> - Specify the working directory path where config-related files will be stored. Default: "~/.wp-staging-cli".
--skip-config - Don't reads command options from the configuration file located at "~/.wp-staging-cli/wp-staging-cli.conf".
--siteurl=<siteurl> - Specify a new Site URL.
--db-prefix=<prefix> - Specify a new database table prefix.
--overwrite=<yes|no> - Overwrite the target directory during `extract` and `restore` operations. Default: "yes".
--verify - Verify the integrity of the extracted file.
--yes - Automatically answers "yes" to confirmation prompts.
--confirm-timeout=<num> - Timeout duration (in seconds) for awaiting a "yes" response at confirmation prompts. Default: 30 seconds.
--skip-extract - Don't extract files and use previously extracted and existing files for `restore` process.
For use case, when restore failed, the process can be continued without first extracting all files again.
-or, --only-wproot - Process only the 'wp root' item in the backup.
-ow, --only-wpcontent - Process only the 'wp-content' item in the backup.
-op, --only-plugins - Process only the 'plugins' item in the backup.
-ot, --only-themes - Process only the 'themes' item in the backup.
-om, --only-muplugins - Process only the 'mu-plugins' item in the backup.
-ou, --only-uploads - Process only the 'uploads' item in the backup.
-ol, --only-languages - Process only the 'languages' item in the backup.
-od, --only-dbfile - Process only the database file in the backup.
-oe, --only-dropins - Process only the dropins file in the backup.
-of, --only-file=<string> - Process only items that match the specified string.
-sr, --skip-wproot - Skip processing the 'wp root' item in the backup.
-sw, --skip-wpcontent - Skip processing the 'wp-content' item in the backup.
-sp, --skip-plugins - Skip processing the 'plugins' item in the backup.
-st, --skip-themes - Skip processing the 'themes' item in the backup.
-sm, --skip-muplugins - Skip processing the 'mu-plugins' item in the backup.
-su, --skip-uploads - Skip processing the 'uploads' item in the backup.
-sl, --skip-languages - Skip processing the 'languages' item in the backup.
-sd, --skip-dbfile - Skip processing the database file in the backup.
-se, --skip-dropins - Skip processing the dropins file in the backup.
-sf, --skip-file=<string> - Skip processing items that match the specified string.
-dm, --dump-metadata - Display backup metadata from the backup file.
-di, --dump-index=<data> - Display backup index from the backup file. Use 'data' to show additional information.
-dh, --dump-header - Display backup header from the backup file.
-do, --dump-options - Display the command options that have been parsed.
-d, --debug - Display debug message.
-q, --quiet - Suppress output of processed backup items.
-v, --version - Display version information.
-h, --help - Display all help message.
Restore Options:
-p, --path=<path> - Specify the WordPress root path for restoration. Default: "./".
-wd, --overwrite-db=<yes|no> - Remove database tables not present in the backup. Default: "yes".
-wr, --overwrite-wproot=<yes|no> - Remove files in the WordPress root path that are not in the backup or part of WordPress core. Default: "no".
--db-innodb-strict-mode - Enable InnoDB strict mode if needed. By default, it is turned off during database restoration.
--db-file=<file> - Use the extracted backup SQL file to resume database restoration in case of failure.
--db-insert-batch-size=<num> - Number of queries to batch in a single insert operation. Default: 1000.
--db-insert-multi=<yes|no> - Use multi-row INSERT statements per query to improve performance. Default "yes".
Restore DB Options:
This option overrides the DB-related configuration parsed from the wp-config.php file.
--db-host=<string> - Database Host.
--db-name=<string> - Database Name.
--db-user=<string> - Database User.
--db-pass=<string> - Database Password.
--db-socket=<file> - MySQL socket file path.
--db-charset=<string> - Database charset.
--db-collate=<string> - Database collate.
--db-ssl-ca-cert=<file> - SSL CA file path.
--db-ssl-cert=<file> - SSL certificate file path.
--db-ssl-key=<file> - SSL key file path.
--db-ssl-mode=<mode> - Connects to the database with SSL mode "skip-verify" or "preferred". Default: "skip-verify".Exemples :
wp-staging-cli --license=WPSTGPRO_LICENSE --outputdir=./wpstgbackup backup.wpstg
wp-staging-cli --license=WPSTGPRO_LICENSE --normalizedb --dbprefix=newprefix --siteurl=https://example.com backup.wpstgAvec les options courtes :
wp-staging-cli -l WPSTGPRO_LICENSE -o ./wpstgbackup backup.wpstg
wp-staging-cli -l WPSTGPRO_LICENSE -n -dp newprefix -su https://example.com backup.wpstgDéfinir la clé de licence via une variable d’environnement
L’extracteur autonome nécessite une licence WP Staging Pro active (plan Agency ou Developer).
Pour plus de commodité, tu peux définir la clé de licence en utilisant une variable d’environnement :
Sur les systèmes Unix :
export WPSTGPRO_LICENSE=WPSTGPRO_LICENSE_KEYÀ l’invite de commandes Windows :
set WPSTGPRO_LICENSE=WPSTGPRO_LICENSE_KEYContribuer à wp-staging-cli
Nous accueillons avec plaisir les contributions à wp-staging-cli ! Si tu as des suggestions, des rapports de bugs ou si tu veux contribuer du code, ouvre une issue dans le dépôt GitHub.
Articles connexes
- WordPress n’a pas de préfixe de table de base de données. Comment le corriger.
- Comment utiliser WP Staging | Restore. Un installateur WordPress autonome et outil de restauration de Backup
- Mettre à jour le cœur de WordPress manuellement si la mise à jour automatique ne fonctionne pas
- Comment désactiver les tâches cron WordPress (sur un site de staging)
- Comment résoudre l’erreur WordPress « Failed to open stream » ?