How to Test Your WordPress Restore Process (Staging Site)
Having automated backups is great, but how do you know they actually work? A failed restore during a real emergency is a nightmare scenario. The professional way to validate your backups is to periodically restore them to a separate, temporary "staging" server.
This guide shows you how to restore your site to a different server to confirm your backups are valid, without ever touching your live production site.
1. Prerequisites: The Staging Server
You need a second, clean Ubuntu server to act as your temporary staging environment. This can be another virtual machine, a different cloud instance, or even a local WSL environment.
- Set up a LAMP Stack: Your staging server needs a web server, database, and PHP.
- Reference: Setting Up a LAMP Stack on Ubuntu
- Install and Configure
rclone: Installrcloneand configure it with the exact same remote you use for your live site's backups (e.g.,gdrive).- Reference: Syncing Backups to the Cloud with
rclone
- Reference: Syncing Backups to the Cloud with
2. Initial Restore
Follow the standard restore process to get the files and database onto your new staging server.
- Download Backups: Use
rclone syncto pull the backup files from your cloud storage to the staging server's/var/backups/wordpressdirectory. - Create Database & User: Create the
wordpressdatabase andwp_userin MySQL. - Import Database: Restore the
.sqlbackup file into the newly created database. - Extract Files: Extract the
.tar.gzfile backup into the/var/www/htmldirectory.
- Reference: For detailed commands, follow steps 1-4 in the Disaster Recovery Restore Guide.
STOP! Do not proceed to the final step of that guide yet.
3. The Critical Step: Update Site URLs
If you try to access your staging site now, WordPress will immediately redirect you to your live site's domain. This is because the live URL is stored in the database we just restored. We must change it to the staging server's IP address.
- Log into MySQL:
sudo mysql - Select the WordPress database:
USE wordpress; - Find your staging server's IP address:
- Run
ip ain a separate terminal to get the IP (e.g.,192.168.1.100).
- Run
- Run the update commands:
- Replace
YOUR_STAGING_IPwith the actual IP address. - This tells WordPress that its new "home" is the staging server's IP.
UPDATE wp_options SET option_value = 'http://YOUR_STAGING_IP' WHERE option_name = 'siteurl'; UPDATE wp_options SET option_value = 'http://YOUR_STAGING_IP' WHERE option_name = 'home';
- Replace
- Apply changes and exit:
FLUSH PRIVILEGES; EXIT;
4. Finalization and Verification
Now you can safely finalize the setup.
- Fix Permissions: Set the correct file ownership and permissions on
/var/www/html.- Reference: Securing a WordPress Installation
- Test the Site: Open a web browser and navigate to
http://YOUR_STAGING_IP.
You should see a perfect copy of your live site, but running entirely on your temporary staging server. You can now log in, click around, and verify that all posts, pages, and images have been restored correctly.
5. Cleanup
Once you have confirmed your backups are working, you can safely delete the staging server to avoid confusion or extra costs.
Pro Tip: For a more advanced staging environment where you need to fix many internal links (e.g., in image paths), you can install a plugin like "Better Search Replace" on the staging site. Use it to search for
https://www.yourlivesite.comand replace it withhttp://YOUR_STAGING_IP.