All-in-One WP Migration S3 Client Extension WP CLI Integration
The All-in-One WP Migration S3 Client Extension integrates with WP-CLI, allowing you to run migrations from the command line. It includes backup and restore commands that can be executed from the command line.
Backup
Creates a new backup file.
Example: wp ai1wm s3-client backup.
OPTION | DESCRIPTION | EXAMPLE |
---|---|---|
[--sites] | Create a new backup file for WP Multisite (Sub-Sites/Subdomain-Sites). | wp ai1wm s3-client backup --sites |
[--exclude-spam-comments] | Creates a backup file without spam comments. | wp ai1wm s3-client backup --exclude-spam-comments |
[--exclude-post-revisions] | Creates a backup file without post revisions. | wp ai1wm s3-client backup --exclude-post-revisions |
[--exclude-media] | Creates a backup file without media library files. | wp ai1wm s3-client backup --exclude-media |
[--exclude-themes] | Creates a backup file without any themes. | wp ai1wm s3-client backup --exclude-themes |
[--exclude-inactive-themes] | Creates a backup file without currently inactive themes. | wp ai1wm s3-client backup --exclude-inactive-themes |
[--exclude-muplugins] | Creates a backup file without must-use plugins. | wp ai1wm s3-client backup --exclude-muplugins |
[--exclude-plugins] | Creates a backup file without plugins. | wp ai1wm s3-client backup --exclude-plugins |
[--exclude-inactive-plugins] | Creates a backup file without currently inactive plugins. | wp ai1wm s3-client backup --exclude-inactive-plugins |
[--exclude-cache] | Creates a backup file without cache files. | wp ai1wm s3-client backup --exclude-cache |
[--exclude-database] | Creates a backup file without the database. | wp ai1wm s3-client backup --exclude-database |
[--exclude-email-replace] | Creates a backup file without replacing email domain. | wp ai1wm s3-client backup --exclude-email-replace |
[--replace "find" "replace"] | Finds and replaces text in the database. Use --replace flag before each pair for replacement. | wp ai1wm s3-client backup --replace "wordpress" "WordPress" |
SIMULTANEOUS USE | All options be used simultaneously except --list can. Replace option could be used between other options. | wp ai1wm s3-client backup--exclude-inactive-themes --replace "find" "replace" --exclude-cache --replace "old text" "new text" |
List backups
List backup files from S3 Client.
Example: wp ai1wm s3-client list-backups.
OPTION | DESCRIPTION | EXAMPLE |
---|---|---|
[--folder-path= | List backups in a specific subfolder. (Bucket name is specified in the extension settings). | wp ai1wm s3-client list-backups --folder-path=ugyen |
Restore backup
Restore a backup from S3 Client.
Example: wp ai1wm s3-client restore migration-wp-00970913-895743-931.wpress.
OPTION | DESCRIPTION | EXAMPLE |
---|---|---|
[--folder-path= | Download a backup from a specific subfolder inside the bucket. (Bucket name is specified in the extension settings). | wp ai1wm s3-client restore migration-wp-00970913-895743-939.wpress --folder-path=ugyen |
[--yes] | Auto-confirm the backup on restore. | wp ai1wm s3-client restore migration-wp-00970913-895743-939.wpress --yes |
Retention settings
To keep the most recent backup: wp option update ai1wmne_s3_client_backups 1.
To limit the size of backup: wp option update ai1wmne_s3_client_total 1GB.
Note: You can change the number of recent backups and the size of the backup as your needs dictate.
Setting S3 Client Settings in wp-config.php file
To configure S3 Client Settings as constants in the wp-config.php file
define( 'AWS_API_ENDPOINT', 'value' ); define( 'AWS_BUCKET_TEMPLATE', 'value' ); define( 'AWS_ACCESS_KEY_ID', 'value' ); define( 'AWS_SECRET_ACCESS_KEY', 'value' ); define( 'AWS_DEFAULT_REGION', 'value' );
Setting S3 Settings via CLI
First, register aliases in your project’s wp-cli.yml file, or your user’s global ~/.wp-cli/config.yml file:
@prod:
ssh: de******@*****le.com~/webapps/production
@dev:
ssh: vagrant@192.168.50.10/srv/www/example.dev
@local:
ssh: vagrant:default
@both:
- @prod
- @dev
Next, use the aliases to run the commands to configure S3 Client settings. Note that @prod is the alias as defined in the wp-cli.yml file:
wp @prod option update ai1wmne_s3_api_endpoint '' wp @prod option update ai1wmne_s3_bucket_template '' wp @prod option update ai1wmne_s3_access_key '' wp @prod option update ai1wmne_s3_secret_key '' wp @prod option update ai1wmne_s3_region_name '' wp @prod option update ai1wmne_s3_bucket_name ''
Finally, configure backup schedules using the following commands:
wp @prod option update ai1wmne_s3_bucket_name 'bucket-name' wp @prod option update ai1wmne_s3_folder_name 'path/to/folder' wp @prod option update ai1wmne_s3_cron_timestamp 'unix_time_stamp' wp @prod eval "$model = new Ai1wmne_Settings; $model->set_cron(['daily']);" wp @prod option update ai1wmne_s3_notify_toggle 1 wp @prod option update ai1wmne_s3_notify_error_toggle 1 wp @prod option update ai1wmne_s3_backups 10 wp @prod option update ai1wmne_s3_file_chunk_size 20971520 wp option update ai1wmne_s3_cron_timestamp 1743138300 wp option update ai1wmne_s3_timestamp 1743138300