6. Snapshot API Docs
WPMU DEV is dedicated to supporting advanced users in every possible way. Our Snapshot API Documentation is an ongoing project. Information about new commands will be added here as it becomes available.
6.1 Filters & Actions
Copy chapter anchor to clipboard6.1.1 Filter: wp_snapshot_home_path
Link to chapter 1Description
This filter is used to change the site root of the backups/restores. So, using a deeper directory (eg. ‘/var/web/site/public_html/wp-content/uploads‘) in that filter will make Snapshot begin its backups from there instead of the site’s default root directory.
Usage
add_filter( ‘wp_snapshot_home_path’, ‘snapshot_home_path_custom’ );
Example
6.1.2 Filter: snapshot_tables_for_backup
Link to chapter 1Description
This filter is used to change the list of db tables that will be backed up. So, if it returns wp_posts, only the wp_posts table will be backed up (make sure you use a table that exists in your site).
Similarly, with some PHP code it can be used to exclude specific db tables from your backups (example #2).
Usage
add_filter( ‘snapshot_tables_for_backup’, ‘include_tables’);
Example
#1 Includes only the ‘wp_posts’ table in the backups
#1 Excludes the ‘wp_comments’, ‘wp_commentmeta’ tables from the backups
6.1.3 Filter: snapshot4_model_restore_files_paths_limit
Link to chapter 1Description
This filter is used to change the size of the batches used for file restoration. If server resources prevent a file restoration to be performed successfully, the user can try a lower batch size (default batch size is 250).
Usage
add_filter( ‘snapshot4_model_restore_files_paths_limit’, ‘files_paths_limit’ );
Example
6.1.4 Filter: snapshot4_model_restore_db_lines_limit
Link to chapter 1Description
This filter is used to change the size of the batches used for table restoration. If server resources prevent a table restoration to be performed successfully, the user can try a lower batch size (default batch size is 250).
Usage
add_filter( ‘snapshot4_model_restore_db_lines_limit’, ‘db_lines_limit’ );
Example
6.2 WP-CLI
Copy chapter anchor to clipboardWP-CLI is the command-line interface for WordPress. You can update plugins, configure multisite installations and much more, without using a web browser. Snapshot has an integration module with WP CLI, which will allow you to simplify a few common tasks.
Command
wp snapshot backup [command] [id] [args]
Parameters
Examples
List all backups and include ID, date, name and size for each:
wp snapshot backup list
Initiate a backup:
wp snapshot backup run
Initiate a backup and give it a name:
wp snapshot backup run --name="Backup name"
Initiate a backup and apply exclusions as set in the plugin UI:
wp snapshot backup run --apply-exclusions
Initiate a backup, give it a name, and apply exclusions as set in the plugin UI:
wp snapshot backup run --name="Backup name" --apply-exclusions
Get a link to download the latest backup:
wp snapshot backup download
Get a link to download a backup specified by ID:
wp snapshot backup download id
Force download the latest backup, even if it was exported earlier:
wp snapshot backup download --force
Force the download of a backup specified by ID:
wp snapshot backup download id --force
Get a link to download the latest backup and also send an email (note that –force is implied when using –send-email):
wp snapshot backup download --send-email
Get a link to download a backup specified by ID and also send an email:
wp snapshot backup download id --send-email
Check if a backup is currently in progress:
wp snapshot backup status
Show the latest backup log:
wp snapshot backup log
Show the log for a backup specified by ID:
wp snapshot backup log id
Show only errors from the latest backup log:
wp snapshot backup log --errors
Show only warnings and errors from the latest backup log:
wp snapshot backup log --warnings
Show only error log for a backup specified by ID:
wp snapshot backup log id --errors
Show only warnings and errors log for a backup specified by ID:
wp snapshot backup log id --warnings
6.3 Get Support
Copy chapter anchor to clipboardIf you still have questions or need assistance after reading this document, please don’t hesitate to contact our support superheroes using the available options under the Support tab in your Hub or via the Support tab in your WPMU DEV Dashboard.