December 15, 2019

[OwnServer] back up Google Drive, Google Photos, One Drive

This is a note on backing up Google Drive, Google Photos, One Drive.

'rclone' alone can do all of below.  Since I tried different methods, I'm leaving it here for a reference purpose.  I now use rclone for all of the cloud storage sync, without any cloud specific clients.  And there is a software called 'rclone browser' for linux (and Windows) that lets you browse directories and files the cloud storage.

Usage of Cloud (online storage with sync feature):
  • Google Drive: I use paid Google drive, which also allows original file size to be backed up to Google drive/photos.  Family members share documents using Google docs.
  • Google Photos: My kids use google photos, free version for backing up for their photos on their devices.  
  • One Drive: Kids use One Drive to back up their PC files.

Environment: Ubuntu 16

One Drive

Use 'rclone'


This is how I installed on my Ubuntu 16.

$ curl -O
$ unzip
$ cd rclone-*-linux-amd64
$ sudo cp rclone /usr/bin/
$ sudo chown root:root /usr/bin/rclone
$ sudo chmod 755 /usr/bin/rclone
$ sudo mkdir -p /usr/local/share/man/man1
$ sudo cp rclone.1 /usr/local/share/man/man1/
$ sudo mandb

Also, install the binary on Windows.  Since my linux box is headless, I need a web browser for auth thus using browser on Windows.

Set up

On linux side:
$ rclone config
> select 'n' for new remote
> type name, 'onedrive-keith'
> select '22' for one drive storage
> enter blank for client id, client secret
> advanced set up -> select 'n'
> auto config -> select 'n'
> will wait for "result" from windows

On windows side:
C:\> rclone authorize "onedrive"
> browser will pop up, give permission to onedrive with your account by clicking on "Yes"
> go back to cmd, and will give some result
> copy and paste the result into linux console

Back to linux:
> select '1' for onedrive personal
> select '0' for personal
> select 'y' for "Found drive 'root' of type 'personal', URL:...."
> select 'y' for "Yes this is ok"


e.g. added to cron entry similar to this:

$ rclone sync -P --create-empty-src-dirs onedrive-keith: /mnt/data1/OneDrive/keith

To install, just follow the "One Drive Doc" steps.  Once it's configured by running: rclone config, the configuration is stored at /home/kkim/.config/rclone/rclone.conf

Above "onedrive-keith" is just the configuration entry name.

Google Photos

I don't remember why I did not use rclone for Google Photos -- it's been a while, but I used another s/w called 'gphotos-sync'.

Read this doc,

On Ubuntu 16, I had Python 3.5, and it requires 3.6+.  Below is removing 3.5 and installing 3.7:
$ sudo apt-get remove --auto-remove python3.5
--- install python3.6 or 3.7
$ sudo apt update
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:deadsnakes/ppa
$ sudo apt update
$ sudo apt install python3.7
$ python3.7 -v

Install pip3
$ curl -o
$ sudo python3.7

And install gphotos-sync
$ sudo pip install gphotos-sync

Configuration is well explained in the mentioned web page (and it's several steps) -- it requires setting up Google API with each one's account.

Once configured in Google API, download client secret JSON file and stored on Ubuntu.  This will also require to use Windows (or any desktop with GUI) browser to configure Google API and for auth.


$ gphoto-sync [backup path] --secret [client_secret.json]

Google Drive

Again, I don't remember why I decided to use another software and not rclone.  I used 'grive'.  Similar to Google Drive, One Drive, it requires using web browser to configure API and get authenticated.

See this page for installation and configuration steps:

Source code is at:

Install Steps

$ sudo apt-add-repository ppa:nilarimogard/webupd8
$ sudo apt-get update
$ sudo apt-get install grive


After set-up is done, get client ID and client secret strings. 

$ pushd [BACKUP PATH]
$ grive -i [CLIENT ID] -e [CLIENT SECRET] sync
$ popd

I've created bash scripts to simplify above and added to cron.  So the backup of backup is available on my home server.  If there is any issue with internet, or any of the cloud services, devices are lost or corrupted, the files are available on my server.

About Backup

From my experience, having (at least) 3 copies is the safest practice.  One on the device being used, and two additional backups:

10's-20's -- on original device, cloud, backup server, external HDD, USB flash drive
00's-10's --  on original device, cloud, external HDD, USB flash drive
90's-00's -- on original device, external HDD, CD/DVD
80's-90's -- on original device, floppy, tape drive

I tried complete online backup solution, and I think it's not worth it.  The software degrades the computer performance, back up is slow (over the net), and vendor lock-in is an issue.  Store on cloud just some files, and using external HDD/local server for complete backup is most practical solution.

No comments: