UpdraftPlus
Back up, restore and migrate your WordPress website with UpdraftPlus
UpdraftPlus provides a number of ways to exclude files or directories from the backup.
These are:
Any files or directories that you directly list will be excluded. You can use a wildcard at the beginning or end, in order to exclude any files or directories at the top level matching that pattern. (The default setting uses this to exclude backups created by a number of other plugins). The above screenshot excludes any files or directories in ‘Uploads’ whose names begin with ‘Backup’, and also excludes the entire directory 2015/05 (i.e. wp-content/uploads/2015/05).
You can add as many as you like; to do so, separate them with commas. (But not with spaces – a comma only). Also, make sure that you’re adding them to the correct setting.
If you create a file called “.donotbackup” (without the quotes) in any directory, then that directory (and its sub-directories) will be excluded from the backup.
You can exclude files with chosen extensions by either:
a) Adding them to the exclusion setting (see 1, above), by identifying them with “ext:”; e.g. ext:mp3,ext:mp4.
b) Or, you can add a line in your wp-config.php to define the constant UPDRAFTPLUS_EXCLUDE_EXTENSIONS
; for example (again, extensions are separated by commas, only):
define('UPDRAFTPLUS_EXCLUDE_EXTENSIONS', 'mp3,mp4');
This is the counter-part of excluding files based upon the suffix in their filename; you can also do it via prefix (i.e. the characters that begin the filename). To do this, add them to the exclusion setting (see 1, above), by identifying them with “prefix:”; e.g. prefix:abc will exclude any files whose names begin with abc.
You can write a small code snippet (e.g. as an mu-plugin, or in your child theme’s functions.php file) to exclude any directory you desire from the backup, using a WordPress filter.
You can make the code as simple or complicated as you like. The filter to use is updraftplus_skip_directory
, which returns a boolean (true to skip, or false (the default) to not skip), and whose other parameter is the full directory path.
Here is an example of a code snippet to skip all .git directories:
add_filter('updraftplus_exclude_directory', 'my_updraftplus_exclude_directory', 10, 2);
function my_updraftplus_exclude_directory($filter, $dir) {
return (basename($dir) == '.git') ? true : $filter;
}
In the same way as described above for directories, there is a filter updraftplus_exclude_file
which you can use to prevent the backup of particular files. The below example will prevent the backup of any files called bertie.jpg :
add_filter('updraftplus_exclude_file', 'my_updraftplus_exclude_file', 10, 2);
function my_updraftplus_exclude_file($filter, $file) {
return (basename($file) == 'bertie.jpg') ? true : $filter;
}
Try TeamUpdraft’s full suite of WordPress plugins.
Back up, restore and migrate your WordPress website with UpdraftPlus
Speed up and optimize your WordPress website. Cache your site, clean the database and compress images
Secure your WordPress website. Comprehensive, feature rich and easy to use
Centrally manage all your WordPress websites’ plugins, updates, backups, users, pages and posts from one location