Recently, I got an issue with my website backups so I moved my website Into a fresh VPS with VestaCP and started researching how to upload VestaCP backups to my cloud drives to keep them safe and I found a solution to backup vestacp files to Google drive automatically.
Currently im running VestaCP in Centos 6 but this tutorial may work in all Centos Versions.
How to backup VestaCP files to Google Drive automatically
We have to install a third-party CLI tool which lets you simply transfer files to your Google Drive with scripts.
wget -O drive https://drive.google.com/uc?id=0B3X9GlR6EmbnMHBMVWtKaEZXdDg mv drive /usr/sbin/drive chmod 755 /usr/sbin/drive
This is a tool to upload files using OAuth2, this does not sync.
It will ask for verification code like this :
Go to the following link in your browser: https://accounts.google.com/o/oauth2/auth?client_id=123456789123-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: ENTER YOUR VERIFICATION CODE BY GOING ABOVE LINK
Now we have created link between our server and Google Drive. Now we can upload our files to Google drive.
Now create a file
tech4bros.sh with the following code in
drive upload --file "admin.$(date '+%Y-%m-%d').tar"
Now Add it on Corn Job to run it automatically
echo "0 2 * * * root /home/backup/tech4bros.sh >> /etc/crontab
Now the cornjob runs it daily on 2AM.
If you have modifications or problem in using it, share it on the common section below.