Backup Data before Removal
SweepPress Pro can back up data into SQL export file (using SQL INSERT INTO format), before removing data done by sweepers or via management panels. The backup is targeted, and only records that will be removed are exported. Because of that, you get the file containing exactly what is removed, and you can later quickly import those records back into the database.
This feature is not available in the Lite version of the plugin!
To configure the backup, you have only few options to configure, via the plugin settings. And, to see all the export files, you have the dedicated Sweep Backups panel in the main menu. The plugin dashboard panel shows the Backup Files widget where you can see how many backup files are created, and includes links to Management panel and Tools to remove all backup files at once.
What can be exported into file
SweepPress backup feature supports exporting data removed by most of the sweepers, options, metadata and sitemeta data removed by the management panels. Only few sweepers don’t support backup. Check out the Sweepers List panel fo see which sweepers have backup support, or check out this reference list of all sweepers.
When it comes to management panels, all options, sitemeta and metadata can be exported.
Export files are in the same format used by MySQL native mysqldump export program, and it should be compatible with all versions of MySQL or MariaDB servers.
Export contains complete records, and each one has own INSERT INTO statement. And, each record includes primary key ID, and this will ensure that there is no clash with records added later. But, there are some exceptions to this, where table contains other constraints that may need to be resolved.
How the backup process works
To make sure that each export contains clearly distinct data for each task, plugin will generate smaller files that make easier to find what you need later.
Management Panels Removal
If you use Management panels, every deletion will generate new export file. That means, if you delete only one meta record or option, that one record will be exported into one file. If you use bulk deletion, everything targeting that bulk operation will go into one file. Each deletion action – for single record or in bulk, will generate one file.
Sweepers Data Removal
When it comes to sweepers, each task will generate one export file. So, if you run 5 sweepers, and each one has 3 tasks, you will get 15 export files. This will ensure that unrelated data is not mixed, and make the restore process easier later. And, this helps with listing export files on the Sweep Backups panel and finding exactly what was exported.
Restoring the exports
There is no direct way to import/restore exported data back with the SweepPress plugin. If you want to restore the content of the export file, you need to download the export and use a tool like PHPMyAdmin to import the data from the backup.
While technically not too complicated, importing the content back with the plugin poses several problems and risks that the plugin might not be able to resolve on its own.
It is crucial to follow the import process in whatever tool you use to import the data, and note any errors that can happen.
Potential issues with importing files from SQL exports
The export files are simple, and don’t contain any DELETE or DROP TABLE statements, and are considered safe to import back. But, there are some limitations to the process you need to be aware of.
Unique Column Index
Database tables for Options wp_options and Sitemeta wp_sitemeta contain additional UNIQUE index set on the option name column. So, if your export file contains the record with the option name that already exists in the table, the import for that record will fail.
How can this happen? Well, lets say you have a plugin that adds a record plugin_name_settings. You remove that record via Options Management, and it is exported into the file. After you do that, you activate the plugin that owns that record, and record gets recreated. Now, if you try to import from the export file with plugin_name_settings backup, the import file fail, because only one record with that name can exist in the table.
Changes to Auto Increment of primary Index
If you remove records from any table with a primary index (or key), in WordPress, all those tables have auto increment value, and in theory, the keys will not repeat, and newly created records will have new keys. But, if you made some manual changes to the table, moved and reindex the table (this is not the default database feature, but I have seen tools that do it), it can happen that you changed the primary key values, and if you attempt to import the file, these primary keys may clash.
It is a bad idea to force primary key values, unless you are importing old data. If you want to do that, you can, but make sure you understand the process, and how that can affect the import of other data later own, if the data contains primary key values too.