This article describes how to back up data on your A2 Hosting account to a Google Drive account, as well as how to restore data from Google Drive to your account. Using this configuration, your data is backed up securely to an off-site storage location.
The gdrive program enables you to access and manipulate Google Drive files and directories from the command line.
To install and configure the gdrive program for your account, follow these steps:
cd ~ wget https://github.com/prasmussen/gdrive/releases/download/2.1.1/gdrive_2.1.1_linux_386.tar.gz tar xvzf gdrive_2.1.1_linux_386.tar.gz
To make the gdrive program accessible from any directory in your account, type the following commands:
mkdir ~/bin mv ~/gdrive ~/bin
To configure gdrive to access your Google Drive account, type the following command:
gdrive about
Click Allow:
Click the clipboard icon to copy the verification code:
At the command prompt, paste the verification code that you obtained in step 7, and then press Enter. You should receive the following message (the actual names and amounts will differ):
User: Kelly Koe, [email protected] Used: 181.6 MB Free: 32.1 GB Total: 32.2 GB Max upload size: 5.2 TB
gdrive is now configured to use your Google Drive account.
To list your Google Drive files and directories, type the following command:
gdrive list
This command displays the ID number, name, type, size, and creation date for all of the files and directories in your Google Drive account.
gdrive help
After you install and configure the gdrive program, and have verified that gdrive can connect to Google Drive, you are ready to:
To do this, follow these steps:
gdrive mkdir backups
To verify that the directory was created successfully, type the following command:
gdrive list
Note the ID for the directory, as you will need this information below.
After you verify that the Google Drive directory was created successfully, you are ready to set up a cron job that backs up files to the directory automatically. To do this, the cron command must run the gdrive program with the correct ID of the destination directory.
For example, the following command demonstrates how to back up the entire public_html directory to the Google Drive backups directory daily at 2:30 AM. You should replace username with your own A2 Hosting account username, and replace ID with the ID of the backups directory:
30 2 * * * /home/username/bin/gdrive upload --parent ID --recursive /home/username/public_html
You can also back up individual files. The following cron job shows how to do this with a file named backup.tar.gz:
30 2 * * * /home/username/bin/gdrive upload --parent ID /home/username/backup.tar.gz
To restore data from Google Drive to your A2 Hosting account, follow this step:
gdrive download ID
To restore an entire directory, type the following command. Replace ID with the ID of the directory you want to restore:
gdrive download --recursive ID
Subscribe to receive weekly cutting edge tips, strategies, and news you need to grow your web business.
No charge. Unsubscribe anytime.
Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.
We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.