gdrive
Manage Google Drive files from the command line
TLDR
Upload a local path to the parent folder with the specified ID
Download file or directory by ID to current directory
Download to a given local path by its ID
Create a new revision of an ID using a given file or folder
SYNOPSIS
gdrive [global options] command [command options] [arguments]
PARAMETERS
-c
Specifies an alternative configuration file path for gdrive.
-m
Specifies an alternative MIME type mapping file path.
-v
Enables verbose output, showing more details about operations.
--help
Displays help information for the gdrive command or a specific subcommand.
--version
Shows the gdrive tool version.
about
Displays information about your Google Drive account, including storage usage.
download (dl)
Downloads files or directories from Google Drive. Options include:
-r, --recursive: Downloads folders recursively.
--skip-existing: Skips downloading files that already exist locally.
--path
--no-clobber: Prevents overwriting existing local files.
upload (up)
Uploads files or directories to Google Drive. Options include:
--parent
-r, --recursive: Uploads folders recursively.
--convert: Converts uploaded files to Google Docs formats.
--name
list (ls)
Lists files and folders in your Google Drive. Options include:
-q, --query
-m, --max
-o, --order
sync
Synchronizes a local directory with a Google Drive folder. Options include:
--id
--delete-extraneous: Deletes files on Drive that don't exist locally.
--dry-run: Performs a simulated sync without actual changes.
info
Displays detailed information about a specific file or folder on Google Drive using its ID or path.
mkdir
Creates a new folder on Google Drive.
delete (rm)
Deletes files or folders from Google Drive. Options include:
-r, --recursive: Deletes folders recursively.
--trash: Moves items to trash instead of permanent deletion.
share
Manages sharing permissions for files or folders on Google Drive.
unshare
Removes sharing permissions for files or folders.
cat
Prints the content of a file directly to standard output.
DESCRIPTION
gdrive is a powerful and versatile command-line utility designed to interact with Google Drive directly from your Linux terminal. It provides a comprehensive set of features for managing your cloud storage, including uploading and downloading files, listing directory contents, creating and deleting folders, and synchronizing local directories with Google Drive.
Its non-interactive nature makes it ideal for scripting automated backup and synchronization tasks. gdrive leverages Google's OAuth2 authentication for secure access, guiding the user through a browser-based authentication flow upon its first use. It's an essential tool for users who prefer terminal-based workflows or need to integrate Google Drive operations into shell scripts and cron jobs.
CAVEATS
Initial authentication requires browser interaction to generate a token, which might be challenging in headless environments without a browser.
Google Drive API rate limits can be encountered with frequent or large operations, potentially leading to temporary errors.
Synchronization logic, especially for complex scenarios or large datasets, requires careful configuration to avoid unintended data loss or duplication.
Handling Google Docs/Sheets/Slides formats: gdrive can convert uploaded files to native Google formats, but downloading them typically results in exported versions (e.g., PDF, DOCX), not the editable native format.
AUTHENTICATION PROCESS
Upon first execution, gdrive typically provides a URL. You must open this URL in a web browser, log in with your Google account, grant gdrive permissions, and then copy the authorization code displayed back into your terminal. This process generates a configuration token that gdrive stores for future use, allowing subsequent operations without re-authentication.
FILE IDS
gdrive often refers to files and folders using their unique Google Drive IDs rather than their names, especially for operations like download or info. These IDs can be obtained using the list command. Using IDs ensures precision, as multiple files can share the same name within Google Drive.
HISTORY
gdrive was initially developed by Burman as an open-source project. It provides a simple yet effective way to manage Google Drive files from the command line, gaining popularity for its ease of use compared to more complex cloud storage tools. Its development has focused on providing essential functionalities for typical Drive interactions, making it a go-to tool for scripting and automation of cloud storage tasks on Linux systems.