A CLI tool to archive Google Drive folders and replace them with compressed archives.
Google Drive storage space is often filled with large folders that are rarely accessed but need to be kept for reference or backup purposes. This tool helps you free up storage space by:
- Automatically compressing such folders into high-compression archives
- Replacing the original folders with their compressed versions
- Maintaining the same folder structure and accessibility
This way, you can keep your important data while significantly reducing storage usage.
- Recursively downloads all files from a specified Google Drive folder
- Creates a high-compression tar.xz archive
- Uploads the archive to the parent folder
- Optionally deletes the original folder
pip install gdarch
# Install Poetry (if not already installed)
curl -sSL https://install.python-poetry.org | python3 -
# Clone and install
git clone https://github.com/taross-f/gdarch.git
cd gdarch
poetry install
-
Get OAuth2 credentials from Google Cloud Console:
- Visit Google Cloud Console
- Create or select a project
- Go to APIs & Services > Credentials
- Create an OAuth 2.0 Client ID
- Download the credentials and save as
credentials.json
-
Run the command:
# When installed from PyPI
gdarch --folder-id <TARGET_FOLDER_ID> --credentials credentials.json
# When installed from source (using Poetry)
poetry run gdarch --folder-id <TARGET_FOLDER_ID> --credentials credentials.json
# Archive and delete the original folder
gdarch --folder-id <TARGET_FOLDER_ID> --credentials credentials.json --delete-folder
# Specify a custom archive name
gdarch --folder-id <TARGET_FOLDER_ID> --archive-name my_archive.tar.xz --credentials credentials.json
--folder-id
: Google Drive folder ID to archive (required)--credentials
: Path to OAuth2 credentials file (defaults to credentials.json)--archive-name
: Name for the uploaded archive file (optional)--delete-folder
: Delete the original folder after archiving (flag)
The folder ID is the last part of the Google Drive folder URL:
https://drive.google.com/drive/folders/1234567890abcdef
^^^^^^^^^^^^^^^^
This is your folder ID
# Install dependencies
poetry install
# Run tests
poetry run pytest
# Format code
poetry run black .
poetry run isort .
- Authenticates with Google Drive using OAuth2
- Recursively lists all files in the specified folder
- Downloads files while streaming them directly into a tar.xz archive
- Uploads the compressed archive to the parent folder
- Optionally deletes the original folder
- Cleans up temporary files
MIT License