### Regular backups using Grive2 on Ubuntu

Grive is a Google Drive client for Linux that can do two-side synchronization between Google Drive and a local folder. The synchronization is done whenever the user launches the application, either from a launcher or from command line (it is a CLI application).

By adding grive to crontab, periodic backups of important folders can be made. And no user interaction is required because the process is automated. Here is how to do it in Ubuntu. There is no system load when the process is not running, but this comes with a disadvantage: no filesystem monitoring. Any updates are made during the automatic execution of Grive.

## Grive

The original grive development has been discontinued and it no longer works with the current Google Drive API. A fork named Grive2 can be installed from WebUpd8 repository. Open a Terminal and run the following commands:
sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install grive
Now choose a directory to backup. You must have read/write permissions. I recommend Documents folder. Unfortunately, only one folder can be chosen for backup. While in Terminal cd to that directory. If it is Documents, run cd ~/Documents. Now run Grive: grive -a. The -a argument tells Grive to request the authorization code from Google. This is what you'll see in Terminal:

 Grive authentication
Open that link in browser, log in with your Google Account and if you allow Grive to access your Drive contents, a token will be generated. Copy and paste this code in Terminal. Note that in Terminal there is no Ctrl+V command. You'll have to right-click and select Paste. Now Grive will start the synchronization process. If you have a lot of files and/or a low speed internet connection it may take a while.

Whenever you want to do a manual synchronization you can use one of the methods:

• cd to the folder you backup and simply run grive.
• run grive in any folder with an argument: grive --path /home/<username>/Documents.

## Crontab

Grive won't do backups unless you run it. But being a CLI application which requires no user input to start the backup it can be run from a scheduled task. Instead of manually editing the crontab file, I chose the GUI solution: GNOME Schedule. Install it with sudo apt-get install gnome-schedule. Run it from Dash or from Terminal (gnome-schedule). On the main window, click the drop-down arrow next to New and add a Recurrent Task.

Make it run every week (or how often you want). The command is:
grive --path /home/<username>/Documents

Click the Add button. Now, to test the task, click the Run button in the main window and ignore any warnings.

If you see something like in the below screenshot, everything worked good.

If Grive starts synchronizing again all files and uploads other files than you know you have in the selected folder, it means you got the path wrong. Check again the command and use absolute paths.

Now that everything works, you might want to suppress output from Grive. Edit the task as follows:

What cloud backup solutions do you use on Ubuntu? Have you tried this?