If you use Grive2 to sync your Google account to a Linux desktop or server and want to connect multiple accounts, here's how to do it.
If you're using Grive2 to sync your Google Drive cloud account to a Linux desktop or server, you might be interested in knowing that you can connect multiple accounts with this one piece of software. The process isn't hard--you just have to know the steps to take to connect more than one account. I'll walk you through those steps.
I assume you already have one account configured to sync with Grive2; if not, you can follow the steps as outlined in the post, How to sync your Google Cloud on Linux with Grive2. Once you have that up and running, let's add a second account and get that account syncing.
Log out/log in
First, log out of the first Google account and log into the second one. This is done via the web browser in the standard method: go to Google Drive, click your profile photo in the upper right, and click Sign Out. You then need to sign into Google Drive with the second account.
Create a new folder
We'll continue in the same fashion as we did in the previous article about Grive2 and create a folder for the new account called ~/GOOGLE2 with the command mkdir ~/GOOGLE2. (You can name this folder whatever you like; for instance, name the folder after the associated Google account.) After you create the folder, change into it with the command cd ~/GOOGLE2.
Generate the codes
From within the new folder, issue the command grive -a. This will return a very long link for you to copy and paste into the browser you used to log into the second Google account. After you paste the link, hit Enter on your keyboard.
You will be asked to give permission for Grive2 to access Google. Click Allow, and then you will be presented with a long code. Copy that code back into the terminal window and hit Enter on your keyboard.
Syncing the files
At this point, Grive2 will run the initial sync of your files on this account. Whenever you want/need to sync either of those accounts, all you have to do is change into the folder associated with one of the accounts and issue the command grive. The software will automatically know which account to sync--you don't have to log out and log back in on Google Drive via the web browser to make this work.
You can set this up to autosync in the same manner you did for the original account by making use of Cron. The only difference is the crontab entry will point to the newly created folder associated with the new account. Here's how:
- Open a terminal window.
- Open your user crontab for editing with the command crontab -e.
- Enter this line in crontab: 59 11 * * * grive --path /home/USER/GOOGLE2/ (USER is your actual username).
- Save your crontab file.
Grive2 will sync the proper files to the proper account without anymore interaction.
As simple as it gets
You'd be hard-pressed to find an easier route to syncing multiple Google accounts to a Linux desktop or server. And don't worry--you can sync as many accounts as you need...just remember which directory is associated with which account.
- Slack teams with Google Cloud, adds Docs preview, Drive Bot, and more (TechRepublic)
- How to make the most out of Google Drive on GNOME (TechRepublic)
- How to work offline with Google Drive files (TechRepublic)
- Pro tip: Blacklist files and folders in Insync to prevent filling up Google Drive (TechRepublic)
- Insync takes Google Drive to the next level on Android (TechRepublic)
- Securing Linux Policy (Tech Pro Research)