CLI tool to archive a Google Drive folder and replace it with the archive. Helps to free up Google Drive storage space by compressing rarely accessed folders while keeping them accessible.
Project description
gdarch
A CLI tool to archive Google Drive folders and replace them with compressed archives.
Motivation
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.
Features
- 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
Installation
From PyPI
pip install gdarch
From Source
# 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
Usage
-
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
Options
--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)
Finding Folder ID
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
Development
# Install dependencies
poetry install
# Run tests
poetry run pytest
# Format code
poetry run black .
poetry run isort .
How It Works
- 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
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gdarch-0.1.1.tar.gz.
File metadata
- Download URL: gdarch-0.1.1.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.19 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ff4abee4ad547fefa9869ce9280d9308858b2dd80724e8d5a8fb126a26e8e3e0
|
|
| MD5 |
5884c49103aa1049ef51694be2ea2745
|
|
| BLAKE2b-256 |
6c2c8cfb8fa89325f443086576542b22fe61100bcba11d67791a4208caaf2c9f
|
File details
Details for the file gdarch-0.1.1-py3-none-any.whl.
File metadata
- Download URL: gdarch-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.10.19 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e10b502c9c9852ce9de791e73b733c9659aeb1a0dedfe340fcc968c97d3205a
|
|
| MD5 |
17a80e5abea60f1f96e6733bc01fb1cc
|
|
| BLAKE2b-256 |
0308418cd1a27692674b2a4f5143111379668c63d515117c54123e25632f8f2d
|