Database Snapshots provide an easy and fast way to save the state of WordPress before doing a major action such as activating or deactivating a plugin or theme. Previous state (snapshot) can be restored or compared to the current one with a single click. Snapshots are ideal to asses the footprint a plugin or theme makes and to test complex installation procedures when resetting WordPress each time is not an option.

A Few General Facts About Database Snapshots

  • although snapshots are a form of backup we don’t advise using them for “real” backups on live sites – always save your backups off-site, not it the same, live DB
  • snapshots do not touch files in any way; they don’t save them, make a list of files or do anything with them
  • snapshots are stored as custom database tables; one snapshot table for each original table
  • naming template for snapshot tables is {6_char_random_hex}_{table_prefix_for_your_site}_{original_table_name}
  • besides the default WP DB tables, snapshots save custom tables too, but only ones with the $wpdb->prefix name prefix
  • please mind the total size of your WP tables (size is visible in the box above the list of saved snapshots); when a snapshot is created it will take as much space as the original tables did
  • restoring a snapshot does not affect other snapshots, or WP Reset settings
  • for tables totaling up to 30-ish MB creating and restoring snapshots is borderline instant
  • snapshot metadata is kept in wp-reset-snapshots WP option which is preserved when doing a reset with WPR and all other operations that clean/delete items in options table

Create a New Snapshot

Create Snapshot in WP Reset

Click “Create New” to create a new snapshot. A confirmation dialog appears asking for the snapshot name or brief description. This name servers only as a helpful reminder to you. It’s not mandatory nor used for anything else. If you omit the name a timestamp will be used to identify the snapshot.

A list of tables that will go into the snapshot is generated by running SHOW TABLE STATUS and picking all tables that have a name that starts with $wpdb->prefix. Those tables are then cloned by prepending a unique snapshot ID to their name, ie a51e42_wp01_comments using the following SQL code:

CREATE TABLE $new_table LIKE $original_table;
INSERT $new_table SELECT * FROM $original_table;

As the last step, snapshot metadata is added to the list of snapshots.

Compare Snapshot to Current Database Tables

Compare Snapshots

At the moment you can’t compare two snapshots. Only a selected snapshot and the currently used tables. Click the eye icon in the actions list next to the snapshot’s name to compare it to the currently used database tables.

Compare Snapshots

The color-coded list shows tables that are present only in the snapshot, but not in the current tables as well as tables that are only present in the currently used tables – those are shown in red. In green, you’ll see tables available in both the snapshot and current tables that are the same, have the same structure and the same data. Clicking a table in any situation shows its structure and data details. Tables marked in yellow exist in both data sets but have different structures and/or data. For the wp_options table, you can compare data between the snapshot and current table in a standard diff format.

Restore Snapshot

Restore Snapshot

Click the clock icon in the actions list next to the snapshot’s name to restore the snapshot. A confirmation dialog is displayed. Restoring a snapshot deletes all the current database tables used. Both core and custom ones.

After the integrity of the snapshot is confirmed all database tables with the $wpdb->prefix name prefix are deleted using DROP TABLE. Snapshot tables are then duplicated under a new name. New name is created by removing the snapshot UID from the table namse. For instance, a snapshot table can be named a51e42_wp01_comments but when it’s restored the name would be wp01_comments. Tables are copied using only SQL;

CREATE TABLE $new_table LIKE $snapshot_table;
INSERT $new_table SELECT * FROM $snapshot_table;

Download Snapshot

Download Snapshot

Click the export icon in the actions list next to the snapshot’s name to delete it. A dialog with a direct download link is displayed once the export is generated.

Snapshot exports are saved in wp-content/wp-reset-snapshots-export/ in form of a gzipped SQL dump with the filename template wp-reset-snapshot-{snapshot_UID}.sql. Table names in the dump are NOT the original ones. Instead, they have the snapshot UID prefix. For instance a51e42_wp01_comments. Have that in mind when using the dump – tables have to be renamed, the prefix removed.

Delete Snapshot

Delete Snapshot

Click the download icon in the actions list next to the snapshot’s name to download it as an SQL dump file. A confirmation dialog is displayed.

A list of snapshot’s tables is generated by searching through the database for tables with the unique snapshot ID. Then tables are deleted with DROP TABLE and snapshot metadata is removed from the list of snapshots.