Google Drive: using via terminal on Linux Debian 9 with insync-headless
Tags: linux, google
Published: 2020-04-24 11:46:48

---
title: Google Drive: using via terminal on Linux Debian 9 with insync-headless
published: true
date: 2020-04-24 08:03:19 UTC
tags: Linux, Google
canonical_url: https://rtfm.co.ua/en/google-drive-using-via-terminal-on-linux-debian-9-with-insync-headless/
---

[![](https://rtfm.co.ua/wp-content/uploads/2019/03/google-adsense-logo-130.png)](https://rtfm.co.ua/wp-content/uploads/2019/03/google-adsense-logo-130.png) ![](https://rtfm.co.ua/wp-content/uploads/2020/04/5847faf6cef1014c0b5e48cd.png)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](https://rtfm.co.ua/en/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](https://www.insynchq.com/) (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](https://help.insynchq.com/en/articles/2853764-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](https://insynchq.com/auth) and log in with your Google used for Insync, and get your auth-code:

[![](https://rtfm.co.ua/wp-content/uploads/2020/04/Screenshot_20200423_161704.png)](https://rtfm.co.ua/wp-content/uploads/2020/04/Screenshot_20200423_161704.png)

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>>>](https://forums.insynchq.com/t/how-to-control-insync-1-x-via-command-line-interface-cli/34).

### Similar posts

- <small>01/07/2020</small> [Calibre Web: home in-browser online-library with Nextcloud storage and Moon+ Reader on Android](https://rtfm.co.ua/en/calibre-web-home-in-browser-online-library-with-nextcloud-storage-and-moon-reader-on-android/)