git-annex-remote-googledrive

PyPI version

git-annex special remote for GoogleDrive

git-annex-remote-googledrive adds direct and fast support for Google Drive to git-annex and comes with some awesome new features.

IMPORTANT: Google has started to lockdown their Google Drive API. This might affect access to your remotes. See Google Drive API lockdown

Features

Installation

pip3 install git-annex-remote-googledrive

For Arch Linux, there is a package available in the AUR

Usage

  1. Create a git-annex repository (walkthrough)
  2. In the repository, run git-annex-remote-googledrive setup and follow the instructions to authenticate with your Google account.
  3. Add a remote for Google Drive. This example:

    • Adds a git-annex remote called google
    • Encrypts all chunks prior to uploading and stores the key within the annex repository
    • Stores your files in a folder/prefix called git-annex:
git annex initremote google type=external externaltype=googledrive prefix=git-annex encryption=shared mac=HMACSHA512

The initremote command calls out to GPG and can hang if a machine has insufficient entropy. To debug issues, use the --debug flag, i.e. git-annex initremote --debug.

Options

Options specific to git-annex-remote-googledrive

General git-annex options

Using an existing remote

If you’re switching from any other special remote that works with Google Drive (like git-annex-remote-rclone or git-annex-remote-gdrive), it’s as simple as typing git annex enableremote <remote_name> externaltype=googledrive. The layout setting will be automatically imported.

Repository layouts

The following layouts are currently supported:

You can switch layouts at any time using git annex enableremote <remote_name> layout=<new_layout>. git-annex-remote-googledrive will then start to store new keys in the new layout. It will always find existing keys, no matter in which layout they are stored. Existing keys will be migrated to the current layout when accessed. Thus, to bring the remote in a consistent state, you can run git annex fsck --from <remote_name> --fast.

Fix full folder

Since June 2020, Google enforces a limit of 500 000 items per folder, which makes the initial default layout nodir a bad choice. If you switch to a different layout before reaching the limit, then all is fine and git-annex-remote-googledrive will migrate automatically. However, if you’ve already hit the limit, additional steps need to be taken. In order to make the remote operational again, it needs to be able to create folders inside the base folder, thus we need to get below the limit. The simplest way to achieve this is to

git-annex-remote-googeldrive can do those steps for you. In order to do this, you need to issue git annex enableremote <remote_name> auto_fix_full=yes. Next time it can’t store a new key due to the limit, it will perform the above steps to migrate to the new layout.

As git-annex-remoge-googledrive is able to find any key that is inside its root folder, it will figure out the rest from here. You can run an fsck if you want, to get it to a consistent state, but that’s not mandatory.

Google Drive API lockdown

Google has started to lockdown their Google Drive API in order to enhance security controls for the user. Developers are urged to “move to a per-file user consent model, allowing users to more precisely determine what files an app is allowed to access”. Unfortunately they do not provide a way for a user to allow access to a specific folder, so git-annex-remote-googledrive still needs access to the entire Drive in order to function properly. This makes it necessary to get it verified by Google. Until the application is approved (IF it is approved), the OAuth consent screen will show a warning (#31) which the user needs to accept in order to proceed.

It is not yet clear what will happen in case the application is not approved. The warning screen might be all. But it’s also possible that git-annex-remote-googledrive is banned from accessing Google Drive in the beginning of 2020. If you want to prepare for this, it might be a good idea to look for a different cloud service. However, it seems that rclone got approved, so you’ll be able to switch to git-annex-remote-rclone in case git-annex-remote-googledrive is banned. To do this, follow the steps described in its README, then type git annex enableremote <remote_name> externaltype=rclone rclone_layout=nodir. This will not work for export-remotes, however, as git-annex-remote-rclone doesn’t support them.

If you use git-annex-remote-googledrive to sync with a GSuite account, you’re on the safe side. The GSuite admin can choose which applications have access to its drive, regardless of whether it got approved by Google or not.

Issues, Contributing

If you run into any problems, please check for issues on GitHub. Please submit a pull request or create a new issue for problems or potential improvements.

License

Copyright 2017 Silvio Ankermann. Licensed under the GPLv3.