loading...

Google Drive: using via terminal on Linux Debian 9 with insync-headless

setevoy profile image Arseny Zinchenko Originally published at rtfm.co.ua on ・3 min read

I’d like to attach a Google Drive with my Calibre books library to a Debian host because to run the Calibre Web application, as Nextcloud with a big data not too much stable and I have around 5 GB of books (see the Calibre Web: home in-browser online-library with Nextcloud storage and Moon+ Reader on Android post).

After some ingestion over existing clients, I decided to use the Insync (15 days trial, 30 USD cost for one user).

The latest version can easily be installed from a repository – but it doesn’t support CLI anymore.

So, to install it add a key:

root@rtfm-do-production:/opt# apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ACCAF35C
Executing: /tmp/apt-key-gpghome.mCNEtjtItQ/gpg.1.sh --keyserver keyserver.ubuntu.com --recv-keys ACCAF35C
gpg: key A684470CACCAF35C: 1 signature not checked due to a missing key
gpg: key A684470CACCAF35C: public key "Insynchq Inc <services@insynchq.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1

Create a /etc/apt/sources.list.d/insync.list file:

deb http://apt.insync.io/debian stretch non-free contrib

And install it:

root@rtfm-do-production:/opt# apt update && apt -y install insync

insync-headless

But there is another story with the insync-headless, which actually provides CLI – its support was dropped in the latest versions, see the (LINUX) Headless and CLI community support for more details.

Still, you can use the older version, particularly 1.5.7.

Download its package:

root@rtfm-do-production:/tmp# wget https://d2t3ff60b2tol4.cloudfront.net/builds/insync-headless_1.5.7.37371-wheezy_amd64.deb

Install it:

root@rtfm-do-production:/tmp# dpkg -i insync-headless_1.5.7.37371-wheezy_amd64.deb

Start the service:

root@rtfm-do-production:/tmp# insync-headless start

In your browser navigate to the https://insynchq.com/auth and log in with your Google used for Insync, and get your auth-code:

Authenticate your CLI application using the code above:

root@rtfm-do-production:/tmp# insync-headless add_account -a 4/z***MIA

Synchronization will be started once you’ll add an account:

root@rtfm-do-production:/tmp# ls -l /root/user@gmail.com/
total 1928
-rw-r--r--   1 root root     210 Jun  4  2019 Apartments.gdsheet
-rw-r--r--   1 root root     171 Oct  1  2015 Blank Flowchart.gdlink
drwxr-xr-x 113 root root    4096 Apr 23 16:07 CALIBRE
drwxr-xr-x 309 root root   16384 Apr 23 16:07 CloudCalibre
-rw-r--r--   1 root root     206 May 23  2016 DEGREE_Word.gddoc
...

To check its status use:

root@rtfm-do-production:/tmp# insync-headless get_sync_progress
Downloading
Jenkins_ The Definitive Guide - John Ferguson Smart.pdf (0% of 24.6 MB)
The Docker Book - James Turnbull.pdf (0% of 5.6 MB)
Utro novoi ery - Aleksei Doronin.fb2 (0% of 1.2 MB)
metadata.opf (0% of 3.3 KB)
1060 files queued

@ and a directory name

But here is one small caveat: because the path to the folder containing your Google Drive data will have your email in its name with the @ – some applications, like Calibre Web, for example, won’t accept it as a valid pathname.

To solve this we can use well-know crunch – our lovely symlinks:

root@rtfm-do-production:/tmp# ln -s /root/user@gmail.com/CloudCalibre/ /opt/calibre/books

Check it:

root@rtfm-do-production:/tmp# ll /opt/calibre/books/ | head -5
total 2776
drwxr-xr-x  3 root root    4096 Apr 23 16:05 A. A. Orlov
drwxr-xr-x  9 root root    4096 Apr 23 16:06 A. Avramienko
drwxr-xr-x  3 root root    4096 Apr 23 16:06 A. Bielash
drwxr-xr-x  3 root root    4096 Apr 23 16:06 A. B_iuli

See more commands and documentation here>>>.

Similar posts

Posted on by:

setevoy profile

Arseny Zinchenko

@setevoy

DevOps, cloud and infrastructure engineer. Love Linux, OpenSource, and AWS.

Discussion

pic
Editor guide