3 min read

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.

  1. Set up a LAMP Stack: You need Apache, MySQL, and PHP installed.
  2. Install and Configure rclone: You must install rclone and configure it with the exact same remote you used for your backups (e.g., gdrive).

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.

  1. Create a local backup directory:
    sudo mkdir -p /var/backups/wordpress
  2. Sync from the cloud:
    • This command copies the contents of the WordPressBackups folder in your gdrive remote to your local backup directory.
      rclone sync gdrive:WordPressBackups /var/backups/wordpress
  3. Verify: Use ls -l /var/backups/wordpress to confirm your .sql and .tar.gz files have been downloaded.

3. Step 2: Restore the WordPress Database

Before restoring the files, set up the database that WordPress will use.

  1. Create a new database and user: Follow the exact steps from the original installation guide to create the wordpress database and the wp_user.
  2. Import the database backup:
    • Find the name of your latest .sql file.
    • Replace your_strong_password with 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 -p and the password).

4. Step 3: Restore the WordPress Files

Now, extract the archived website files into Apache's web root.

  1. Clear the default web root:
    sudo rm -rf /var/www/html/*
  2. Extract the backup:
    • Find the name of your latest .tar.gz file.
    • The -C / flag is crucial; it tells tar to extract files relative to the root directory, preserving the var/www/html path.
      sudo tar -xzf /var/backups/wordpress/files_backup_YYYY-MM-DD_HHMMSS.tar.gz -C /

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.

  1. Set correct ownership: The web server (www-data) needs to own the files.
    sudo chown -R www-data:www-data /var/www/html
  2. 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

Your site should now be live and fully restored. Navigate to your domain to verify that everything is working as expected.