Restoring a WordPress Site from an rclone Cloud Backup
This guide covers the disaster recovery process: your server has failed, and you need to rebuild your WordPress site from scratch using the off-site backups stored in your cloud provider via rclone.
1. Prerequisites: A New Server
This scenario assumes you are starting with a fresh, clean Ubuntu server.
- Set up a LAMP Stack: You need Apache, MySQL, and PHP installed.
- Reference: Setting Up a LAMP Stack on Ubuntu
- Install and Configure
rclone: You must installrcloneand configure it with the exact same remote you used for your backups (e.g.,gdrive).- Reference: Syncing Backups to the Cloud with
rclone(Follow steps 2 and 3).
- Reference: Syncing Backups to the Cloud with
2. Step 1: Download Backups from the Cloud
First, we need to pull the backup files from your cloud storage down to your new server.
- Create a local backup directory:
sudo mkdir -p /var/backups/wordpress - Sync from the cloud:
- This command copies the contents of the
WordPressBackupsfolder in yourgdriveremote to your local backup directory.rclone sync gdrive:WordPressBackups /var/backups/wordpress
- This command copies the contents of the
- Verify: Use
ls -l /var/backups/wordpressto confirm your.sqland.tar.gzfiles have been downloaded.
3. Step 2: Restore the WordPress Database
Before restoring the files, set up the database that WordPress will use.
- Create a new database and user: Follow the exact steps from the original installation guide to create the
wordpressdatabase and thewp_user.- Reference: Installing WordPress on a LAMP Stack (Follow Step 2 only).
- Import the database backup:
- Find the name of your latest
.sqlfile. - Replace
your_strong_passwordwith your actual database password.mysql -u wp_user -p'your_strong_password' wordpress < /var/backups/wordpress/db_backup_YYYY-MM-DD_HHMMSS.sql(Note: There is no space between
-pand the password).
- Find the name of your latest
4. Step 3: Restore the WordPress Files
Now, extract the archived website files into Apache's web root.
- Clear the default web root:
sudo rm -rf /var/www/html/* - Extract the backup:
- Find the name of your latest
.tar.gzfile. - The
-C /flag is crucial; it tellstarto extract files relative to the root directory, preserving thevar/www/htmlpath.sudo tar -xzf /var/backups/wordpress/files_backup_YYYY-MM-DD_HHMMSS.tar.gz -C /
- Find the name of your latest
5. Step 4: Fix Ownership and Permissions
This is the final, critical step. Files restored from a backup often have incorrect permissions, which will cause your site to show errors.
- Set correct ownership: The web server (
www-data) needs to own the files.sudo chown -R www-data:www-data /var/www/html - Set correct permissions: Apply the standard secure permissions for WordPress.
sudo find /var/www/html/ -type d -exec chmod 755 {} \; sudo find /var/www/html/ -type f -exec chmod 644 {} \; sudo chmod 600 /var/www/html/wp-config.php- Reference: Securing a WordPress Installation
Your site should now be live and fully restored. Navigate to your domain to verify that everything is working as expected.