How to automate backup of your files to your Google drive from Ubuntu 14.04 LTS

None of the available Google drive clients (CLI) offers automated sync of your files to your Google drive. In our previous article, we have shown you how to install and configure your Google drive client, gdrive. Now we will take you one step further, and show you how to make a simple shell script to sync your files to your Google drive.

Create a new shell script:

# vim /user/gdrive.sh

Here is example of a simple script.

#!/bin/bash
cd /user/gdrive/
/opt/gopkg/bin/drive push -no-prompt=true

The last line starts drive from absolute path /opt/gopkg/bin and option -no-prompt=true bypass any prompt that might come up during sync.

If you want to use script to automate backup of your file and keep only files that are not older than 7 days, place the following line before cd command

find /user/gdrive/MailBackup -mtime +7 | xargs rm -fr

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.