How can I exclude a specific table from the backup?

(This capability exists in UpdraftPlus 1.9.65 (free) or 2.9.65 (paid) or later).

Are you sure you want to do this? It’s always better to have too much backed up, than too little. If you are sure, then here’s how it’s done.

This option isn’t directly configurable in the UpdraftPlus settings page, but you can create a WordPress filter to do so, like so:

Step 1: Create a directory wp-content/mu-plugins in your WordPress install, if it does not already exist.

Step 2: Inside that directory, create a file ending in .php (e.g. wp-content/mu-plugins/prevent-table.php), with contents like this:

<?php

add_filter('updraftplus_backup_table', 'my_updraftplus_backup_table', 11, 5);

function my_updraftplus_backup_table($go_ahead, $table, $table_prefix, $whichdb, $dbinfo) {
    $tables_to_not_back_up = array('wp_my_table', 'wp_some_other_table');
    if (in_array($table, $tables_to_not_back_up)) return false;
    return $go_ahead;
}

If your WordPress site disappears, then you had a syntax error in that file. Remove it to get WordPress back!

That’s a very simple example – it will exclude the two indicated tables (the line $tables_to_not_back_up = … – you can add as many as you like, of course). You can make it as complex as you like, using all the supplied information. The $whichdb variable is equal to ‘wp’ for the WordPress database, or an integer from zero upwards for others you have set up (in UpdraftPlus Premium). The $dbinfo variable is an array containing the database information (host, username, password). You can use this information to make sure you’re working on the right database, if you have tables with the same name in multiple databases.

Posted in: Advanced usage, Backing up

twitterlinkedinFacebook