How to Backup WordPress to Google Drive

Introduction

Google offers a free cloud storage service called Google Drive to save files and directories online. It allows users to share all stored documents, files, and photos with other users. It can be accessed from multiple remote devices such as mobiles, tablets, laptops, and PCs. Google Drive is the best option for you if you can't afford a paid storage service.

SnapShooter is a web-based and powerful backup software that allows you to backup your data in a safe and secure location automatically. It provides a user-friendly and web-based control panel to manage and schedule all backup jobs.

This post will show you how to backup WordPress to Google Drive manually and using SnapShooter.

Backup WordPress to Google Drive Manually

In this section, we will show you how to backup WordPress to Google Drive using gdrive utility.

Install and Configure Gdrive

You will need to install gdrive on the server from where you want to backup WordPress to Google Drive. Gdrive is a command-line utility used for interacting with Google Drive. With gdrive, you can manage, upload, download, delete and share files on Google Drive via the command line.

First, install the required dependencies with the following command:

apt-get install musl gnupg2 wget -y

Next, download the latest version of gdrive from the GitHub using the following command:

wget https://github.com/prasmussen/gdrive/releases/download/2.1.1/gdrive_2.1.1_linux_amd64.tar.gz

Once the download is completed, extract the downloaded file with the following command:

tar -xvzf gdrive_2.1.1_linux_amd64.tar.gz

Next, install the gdrive to the system path:

sudo install gdrive /usr/bin/gdrive

Next, you will need to configure gdrive to access Google Drive. You can do it by running the following command:

gdrive about

You will get the following URL to authenticate with your Google account:

Authentication needed
Go to the following url in your browser:
https://accounts.google.com/o/oauth2/auth?access_type=offline&client_id=367116221053-7n0vf5akeru7on6o2fjinrecpdoe99eg.apps.googleusercontent.com&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fdrive&state=state
 
Enter verification code:

Now, open your web browser and access the above URL. You will get the following page:

Click on the Allow button. You should see the Authorization Code on the following page:

Copy the authorization code from the above page and paste it into your command-line interface:

Enter verification code: 4/1AX4XfWgiebPvE0pzQBzltzEYlKi0DMm9UsqLxokCcji0Dq4CGpywZyXX1yQ

Once gdrive is connected with your Google Drive, you will get the following output:

User: Hitesh Jethva, hitjethva75@gmail.com
Used: 550.7 KB
Free: 16.1 GB
Total: 16.1 GB
Max upload size: 5.2 TB

You can verify the gdrive version using the following command:

gdrive version

You will get the following output:

gdrive: 2.1.1
Golang: go1.11.13
OS/Arch: linux/amd64

Use Gdrive to Backup WordPress to Google Drive

At this point, gdrive is configured to manage Google Drive. You can list all available files on your Google Drive using the following command:

gdrive list

You will get the following output:

Id Name Type Size Created
1CUc3AmOVY9V4cJkNNE0ZVvdb-JOtZsnJ Article dir 2022-02-08 12:49:10

First, go to the server from where you want to back up your WordPress, then log in to the MySQL using the following command:

mysql -u root -p

Once you are logged in, list all available databases using the following command:

MariaDB [(none)]> show databases;

Output:

+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| wordpress_db |
+--------------------+

Next, backup the wordpress_db database using the following command:

mysqldump -u root -p wordpress_db > wordpress_db.sql

Next, upload the wordpress_db.sql dump file to the Google Drive using the following command:

gdrive upload wordpress_db.sql

You will get the following output:

Uploading wordpress_db.sql
Uploaded 1uOkXODUgrwF3TRsF6v7Ib0PsC8TGxeMO at 892.7 KB/s, total 1.1 MB

Next, compress the WordPress data directory:

tar -cvzf wordpress.tar.gz /var/www/html/wordpress

Next, upload the WordPress compressed file to the Google Drive:

gdrive upload wordpress.tar.gz

Output:

Uploading wordpress.tar.gz
Uploaded 1naAiAHYSM6jRnmrYrI6TAJtsPgx9IczA at 9.6 MB/s, total 18.7 MB

Next, run the following command to verify the uploaded files:

gdrive list

You will get the following output:

Id Name Type Size Created
1naAiAHYSM6jRnmrYrI6TAJtsPgx9IczA wordpress.tar.gz bin 18.7 MB 2022-05-11 04:00:06
1uOkXODUgrwF3TRsF6v7Ib0PsC8TGxeMO wordpress_db.sql bin 1.1 MB 2022-05-11 03:58:22
1CUc3AmOVY9V4cJkNNE0ZVvdb-JOtZsnJ Article dir 2022-02-08 12:49:10

You can also access your Google Drive via a web browser to see your uploaded backup file as shown below:

Scheduled WordPress Backups SnapShooter

Backup a WordPress website, database (MySQL) and the file system

Get started for free
No credit card required. Cancel anytime!


Was this page helpful?

Thank you for helping us improve!