Extraer Backups en la línea de comandos en Linux, MacOS o Windows

Este artículo explica cómo extraer un Backup de WP Staging en la línea de comandos usando la herramienta wp-staging-cli. Si tienes dificultades con la línea de comandos, puedes usar otra herramienta llamada WP Staging restore tool para hacer lo mismo con una interfaz gráfica.

wp-staging-cli es una potente herramienta de línea de comandos de alto rendimiento diseñada para procesar archivos de Backup de WP Staging desde la línea de comandos en cada sistema operativo principal.

Con esta herramienta, los usuarios pueden extraer, normalizar e inspeccionar el contenido de los archivos de Backup .wpstg creados por el Plugin WP Staging. Este extractor independiente está programado en Go, lo que garantiza una velocidad y eficiencia excepcionales, y funciona de forma independiente de WordPress.

La herramienta de línea de comandos `wp-staging-cli` forma parte del plan Developer y del plan Agency de WP Staging, y puede descargarse desde GitHub.

Características principales

  • Extraer archivos de Backup y base de datos: Accede a todo el contenido de los archivos de Backup .wpstg.
  • Normalización de base de datos: Normaliza los archivos de base de datos dentro del Backup.
  • Volcado de metadatos: Extrae y muestra metadatos del archivo de Backup.
  • Volcado de índice y cabecera: Recupera la información de índice y cabecera del archivo de Backup.

Rendimiento de referencia

wp-staging-cli es excepcionalmente rápido. Por ejemplo, puede extraer un Backup de 20 GB en menos de 36 segundos en un AMD Ryzen™ 7 PRO 7840U con SSD rápido ejecutando Ubuntu 22.04.

Instalación

Paso 1: Descargar los ejecutables

  1. Descarga los archivos ejecutables para Windows, Linux y Mac OS desde aquí.
  2. Extrae el archivo zip y selecciona el binario apropiado para tu sistema operativo de la carpeta build.
  3. (Opcional) Mueve el binario wp-staging-cli a un directorio en tu PATH para acceder fácilmente. Por ejemplo, en Linux:
ShellScript
mv wp-staging-cli /usr/local/bin/

Instrucciones de uso

Para ejecutar wp-staging-cli, usa el siguiente comando:

ShellScript
wp-staging-cli [options] <backupfile.wpstg>
Argumentos
  • <backupfile.wpstg>: Ruta al archivo de Backup de WP Staging que se va a procesar. Este argumento es obligatorio.

Las opciones y los argumentos del comando pueden usarse en cualquier orden.

  • Las opciones pueden llevar un prefijo de guion simple ‘-‘ o doble ‘–‘.
  • Las opciones con valores pueden establecerse con o sin ‘=’.

Opciones

ShellScript
  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".

Ejemplos:

ShellScript
wp-staging-cli --license=WPSTGPRO_LICENSE --outputdir=./wpstgbackup backup.wpstg
wp-staging-cli --license=WPSTGPRO_LICENSE --normalizedb --dbprefix=newprefix --siteurl=https://example.com backup.wpstg

Con opciones cortas:

ShellScript
wp-staging-cli -l WPSTGPRO_LICENSE -o ./wpstgbackup backup.wpstg
wp-staging-cli -l WPSTGPRO_LICENSE -n -dp newprefix -su https://example.com backup.wpstg
Establecer la clave de licencia mediante variable de entorno

El extractor independiente requiere una licencia activa de WP Staging Pro (plan Agency o Developer).
Por comodidad, puedes establecer la clave de licencia mediante una variable de entorno:

En sistemas basados en Unix:

ShellScript
export WPSTGPRO_LICENSE=WPSTGPRO_LICENSE_KEY

En el símbolo del sistema de Windows:

PowerShell
set WPSTGPRO_LICENSE=WPSTGPRO_LICENSE_KEY

Contribuir a wp-staging-cli

¡Son bienvenidas las contribuciones a wp-staging-cli! Si tienes sugerencias, informes de errores o quieres contribuir con código, abre un issue en el repositorio de GitHub.

Updated on mayo 22, 2026

Rene Hermenau

Autor: Rene Hermenau

About the author: René Hermenau is the founder of WP STAGING. He works on WordPress backups, staging, migrations, database handling, and safe deployment workflows.