Skip to content

Using Google Drive to Backup and Restore Data in Ruachost

Ruachost allows you to configure Google Drive as an offsite backup destination for your hosting account. This ensures your website files and databases are securely stored in the cloud and can be restored if needed.

  • Offsite protection: Keeps your data safe even if your hosting server is compromised.
  • Easy access: Manage and download backups directly from your Google Drive account.
  • Automation: Schedule backups to run automatically via cron jobs.
  • Scalability: Use your existing Google Drive storage without additional infrastructure.
  1. Log in to the Google Cloud Console.
  2. Create a new project (e.g. ruachost-backup).
  3. Enable the Google Drive API.
  4. Configure the OAuth consent screen.
  5. Create OAuth client credentials (Desktop app).
  6. Copy the Client ID and Client Secret (you’ll need these later.)

The gdrive command-line tool is used to interact with Google Drive.

  • On your local computer:

    • Download the latest release from GitHub (gdrive).

    • Extract the file and verify installation by running:

      Terminal window
      ./gdrive version
  • On your Ruachost hosting account:

    • Upload the gdrive binary to your account (e.g., into ~/bin/).

    • Make it executable:

      Terminal window
      chmod +x ~/bin/gdrive
  1. Run:

    Terminal window
    gdrive account add
  2. Enter your Client ID and Client Secret.

  3. Open the provided URL in your browser, log in to Google, and approve access.

  4. Export the configuration and upload it to your Ruachost account if needed.

Step 4: Create a Backup Directory in Google Drive

Section titled “Step 4: Create a Backup Directory in Google Drive”
Terminal window
gdrive files mkdir backups
  • Note the directory ID returned, you’ll use this in your cron jobs.

Set up a cron job in cPanel or via SSH to back up your site automatically.

Example: Back up your public_html folder daily at 2:30 AM:

Terminal window
30 2 * * * /home/username/bin/gdrive files upload --parent DIRECTORY_ID --recursive /home/username/public_html

Example: Back up a single archive file:

Terminal window
30 2 * * * /home/username/bin/gdrive files upload --parent DIRECTORY_ID /home/username/backup.tar.gz
  • To restore a single file:

    gdrive files download FILE_ID
  • To restore an entire directory:

Terminal window
gdrive files download --recursive DIRECTORY_ID