Docs / API & Plugin Development / Snapshot 4.0 API Docs

6. Snapshot 4.0 API Docs

Written by Katherine Pannell | Last updated: December 29, 2020
Filters
Change root of backups/restores
/lib/snapshot/helper/class-fs.php
Change tables for backup
lib/snapshot/task/backup/class-dblist.php
File restoration size
lib/snapshot/model/restore/class-files.php
Table restoration size
lib/snapshot/model/restore/class-tables.php

6.1 Filter: wp_snapshot_home_path

Copy chapter anchor to clipboard

Description

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.2 Filter: snapshot_tables_for_backup

Copy chapter anchor to clipboard

Description

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.3 Filter: snapshot4_model_restore_files_paths_limit

Copy chapter anchor to clipboard

Description

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.4 Filter: snapshot4_model_restore_db_lines_limit

Copy chapter anchor to clipboard

Description

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