Skip to main content

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

CI codecov PyPI Downloads

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:

  1. Automatically compressing such folders into high-compression archives
  2. Replacing the original folders with their compressed versions
  3. 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

  1. 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
  2. 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

  1. Authenticates with Google Drive using OAuth2
  2. Recursively lists all files in the specified folder
  3. Downloads files while streaming them directly into a tar.xz archive
  4. Uploads the compressed archive to the parent folder
  5. Optionally deletes the original folder
  6. Cleans up temporary files

License

MIT License

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gdarch-0.1.1.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gdarch-0.1.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

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

Hashes for gdarch-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ff4abee4ad547fefa9869ce9280d9308858b2dd80724e8d5a8fb126a26e8e3e0
MD5 5884c49103aa1049ef51694be2ea2745
BLAKE2b-256 6c2c8cfb8fa89325f443086576542b22fe61100bcba11d67791a4208caaf2c9f

See more details on using hashes here.

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

Hashes for gdarch-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9e10b502c9c9852ce9de791e73b733c9659aeb1a0dedfe340fcc968c97d3205a
MD5 17a80e5abea60f1f96e6733bc01fb1cc
BLAKE2b-256 0308418cd1a27692674b2a4f5143111379668c63d515117c54123e25632f8f2d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page