In this tutorial, I will show an interesting hack on how to backup website to the Google Drive with rclone Linux tool for free.
Nowadays it’s popular to use SSD for most of our applications as it speeds up our web applications greatly. However, SSD’s are still quite expensive and not practical to store large chunks of data.
The issue that I have personally faced is that it’s not practical to make database or web application media copies in a virtual private server with the SSD disk mounted – the disk space is just too expensive. However, there are cloud storage providers like Amazon, Google, DigitalOcean and other ones that offer some cloud space storage, but the main issue is that it still costs money and on low budget projects it just isn’t worth it.
There’s a comparison table for the cheapest available options:
|Provider||Google Drive||Amazon||DigitalOcean||Google Cloud Storage|
|Disk Space||15 GB||100 GB||250 GB||1 GB|
|Price||$0/month||$11.99/month||$5/month||$0.02 – $0.036/month|
However, as you see from the comparison table Google Drive doesn’t cost a penny, which means you can safely backup up to 15 GB of data. In conclusion, this is perfect to backup your SQL data for a few small projects.
Moreover, if you are wondering how to do that using bash/shell then I have already written a great tutorial that you can read here.
In the next chapters, I will show you exactly how to do this using the rclone UNIX command tool that will sync our data to Google Drive.
Install the rclone tool
This is quite simply a straight forward.
curl https://rclone.org/install.sh | sudo bash
Create a Google service account
If you already have a Google account then you can access your Google API console here.
- Create a project in your Google API console
- Go to the API library and enable the Google Drive API here
- Find the service accounts page and create a new account here
- Create a private key, choose JSON format and save the file on your machine
Set up rclone connection
After creating the private key you need to transfer it to your remote server. Create a new file using your favorite editor like nano and copy the contents of the .json file inside there. Name this file
sa_file.json and then set up the rclone using the provided command below:
The configuration process will be quite long, but for the most options, you can just leave blanks, therefore, I am giving you a few suggestions:
- Enter a meaningful name, this will be used when connecting to your drive;
- Leave client_id, client_secret as blanks;
- Give full access to all files on a scope setting;
- root_folder_id can be left as a blank;
- service_acount_file must be a path to your private key that you have created on the previous step. For example,
- Don’t proceed to the advanced config, because it’s not necessary. Choose “no”.
Backup website files manually
Create a bash script and set up the automated cron
In conclusion, the setup process is no that easy I believe it’s worth the time and hassle.
If you liked this hack let me know and smash that like button. Moreover, if you would like to see a video version of this tutorial then comment on the section below. Don’t forget to subscribe to my weekly newsletter for more interesting hacks and tricks.
- Rclone documentation – https://rclone.org/drive/
- By Pierre-Alexandre Losson – https://medium.com/@houlahop/rclone-how-to-copy-files-from-a-servers-filesystem-to-google-drive-aaf21c615c5d
- By Mathias Wagner – https://medium.com/google-cloud/rclone-and-google-drive-3fdfb00f34e8