Instructions to Copy Local Backup to Google Drive as an additional backup copy.

Download GDrive binary

# For x64

wget -O gdrive https://drive.google.com/uc?id=1Ej8VgsW5RgK66Btb9p74tSdHMH3p4UNb&export=download

# More versions:

https://github.com/gdrive-org/gdrive

Move and Permissions

mv gdrive /usr/sbin/gdrive
chmod 755 /usr/sbin/gdrive

Authentication process

To generate the authentication URL just run:

gdrive

# The client must paste the link in his browser. Accept the permission and you will get a verification code. The client must copy the verification code and give us back to paste it into the shell "Enter verification code"
# We have installed GDrive in CWP and connected it to his Google Drive account.

Make a remote parent folder

# Alternative One
The client must go to his Google Drive and create a folder. Then, go to the folder. Now, look at the URL. At the end of the URL, you can see the folder’s path.

Example 1Qaz_xExWqnZV0kIlhV335crKGUMh3wnI is the token folder. The client must give that token.

# Alternative Two
Simply run:

gdrive mkdir <folder name>

This will return the token

Directory 1Qaz_xExWqnZV0kIlhV335crKGUMh3wnI created

Upload a single file **RECOMMENDED**

Example:

tar -czf "/tmp/test-backup-$(date '+%d-%m-%Y').tar.gz" /backup/daily/<user>
gdrive upload --parent 1Qaz_xExWqnZV0kIlhV335crKGUMh3wnI /tmp/test-backup-99-99-9999.tar.gz --delete

Upload multi files and subfolders **NO RECOMMENDED - TOO SLOW**

gdrive upload --parent --recursive 1Qaz_xExWqnZV0kIlhV335crKGUMh3wnI /backup/daily/<user>

Sync folder **NO RECOMMENDED - TOO SLOW**

gdrive sync upload /backup/daily/<user> 1Qaz_xExWqnZV0kIlhV335crKGUMh3wnI

Notes

  • With the above commands you can create a custom cronjob that executes backups unattended.
  • If a file that already exists in the Google Drive folder is uploaded (doesn't apply to the sync command), it isn't overwritten, it creates an exact copy.
  • If the synchronize folder (sync command) is used at least once, it can no longer be used with the upload command.

More info:

https://github.com/gdrive-org/gdrive

 

[tested with CWP7 in JUNE 2019]