Restoring from a Backup
As the customer of Seravo's premium hosting and upkeep you can always contact our customer support (email help@seravo.com) when a backup restore is needed on your WordPress site. Restoring the site from a backup is a part of our routine customer support, free of charge. If need be, below you'll find instructions on how to restore backups yourself.
To restore the site from a backup file, first connect to your site with SSH. Restoring a backup is done by running commands on the command line. First, we'll need to retrieve the site's files (the wp-content directory) and the site's database.
The latest backup can always be found in the /data/backups
directory. From this directory you can copy the latest backed up version of your files with the cp
-command to the desired location.
Restore WordPess files (wp-content)
First we will retrieve the directory that contains all site's files: plugins, themes as well as the files uploaded to the media library.
1. Connect to your site with SSH (see: How do I connect to my WordPress site with SSH/SFTP?)
2. Before you begin, you may create a fresh additional backup with the command wp-backup
if needed.
3. If desired, you can also compare the files of the backups. The command wp-backup-list-changes
lists all files that have changed between present and the latest backup. By using this information you can restore a specific portion of the site. Close the list with Ctrl+Z (or Cmd+Z).
4. The backup files can be found in the directory /data/backups. With the
rdiff-backup -l /data/backups/data
command you can list the backup history.
5. With the following commands we will move to the root of /tmp/ directory and retrieve wp-content from the backup of the desired date/timestamp (example 2022-12-02, format YYYY-MM-DD) – edit this command as needed). The backup will be retrieved into a temporary directory (wp-content-restore-2022-12-02), from which the site can be restored. It's a good idea to include the entire timestamp, such as 2022-12-02T01:27:05
cd /tmp && rdiff-backup -r 2022-12-02T01:27:05 /data/backups/data/wordpress/htdocs/wp-content/ wp-content-restore-2022-12-02
6. With the following command, we move /wp-content/ directory into the /tmp/ directory, and move the restored backup version of wp-content into /htdocs:
mv /data/wordpress/htdocs/wp-content /tmp/wp-content-moved && mv /tmp/wp-content-restore-2022-12-02 /data/wordpress/htdocs/wp-content
7. If we want to remove the wp-content from /tmp/, run the following command:
rm -rf /tmp/wp-content-moved
Please note! Usually the database must also be restored in addition to the wp-content directory. Continue reading further below.
Restoring plugins only
If you need to only restore a part of your WordPress installation, such as only the plugin directory, you can do this by going into the temporary directory we retrieved (wp-content-restore-2022-12-02) and running the following command:
cp -R plugins/ /data/wordpress/htdocs/wp-content
Restoring the site's database
When the website is restored in to a past state, you also should restore your database. This is also done on the command line, so don't close your SSH connection just yet. The backup database can be found in the /data/backups/data/db
directory.
The database backup is also retrieved with the rdiff
command. The name of the database is generated by the system itself, and is named after your website (such as example_a1b2c3.sql). You may also find an additional database file, such as example_a1b2c3.sql.orig – don't use that file when restoring from a backup, as it is an empty database.
1. Look up the name of the database with the following command:
ll /data/backups/data/db
2. Edit the following command's timestamp according to your needs, and add the name of your database, such as example_a1b2c3.sql:
cd /tmp && rdiff-backup -r 2022-12-01T01:27:05 /data/backups/data/db/[database_name].sql db_restore-2022-12-02.sql
3. Import the site's database and purge caches with the following commands:
wp db import db_restore-2022-12-12.sql && wp-purge-cache
More information on rdiff
For additional information on the rdiff-backup -tool and it's use can be found from the rdiff-backup website.
Restoring from a backup in a shadow environment
Sometimes it may be necessary to restore the site from a backup, and set it up and running in a staging environment instead. As the staging environment is a separate instance, it can be used for troubleshooting or retrieving lost data. More information coming soon!