Skip to main content

Back up a local file to a GitHub Gist

Project description

gist-backup

Back up a hardcoded local file to a GitHub Gist — create or update with a single command.

Installation

pip install gist-backup

Setup

Create a GitHub Personal Access Token with the gist scope:

  1. Go to https://github.com/settings/tokens
  2. Generate a new token (classic or fine-grained) with the gist scope
  3. Export it in your shell:
export GITHUB_TOKEN="ghp_your_token_here"

Hardcoded file

By default the package backs up ~/.bashrc. To change this, edit the BACKUP_FILE constant at the top of gist_backup/backup.py before installing.

Usage

Command line

# Back up the default file
gist-backup

# Back up a different file
gist-backup --file ~/dotfiles/.vimrc

# Override description or make it public
gist-backup --description "My .bashrc backup" --public

Python API

import os
from gist_backup import backup

os.environ["GITHUB_TOKEN"] = "ghp_..."

url = backup()                              # uses BACKUP_FILE default
url = backup("~/.vimrc", public=False)     # custom path
print(url)

Return value

Both the CLI and the backup() function return the Gist's HTML URL, e.g.:

https://gist.github.com/your-username/abc123def456

If a Gist containing the same filename already exists in your account it is updated rather than duplicated.

Configuration reference

Constant Default Purpose
BACKUP_FILE ~/.bashrc File to back up
GIST_DESCRIPTION "Automated backup via gist-backup" Gist description
GIST_PUBLIC False Make the Gist public

License

MIT

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

gist_backup-0.1.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

gist_backup-0.1.1-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file gist_backup-0.1.1.tar.gz.

File metadata

  • Download URL: gist_backup-0.1.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for gist_backup-0.1.1.tar.gz
Algorithm Hash digest
SHA256 0dd0acd3f2dfe1ccd21d74328b59d56ac43235dbf02882a7a3eafe70b3ede4b4
MD5 6c032387b2e3abbdce79e74549ea3942
BLAKE2b-256 05533061d7aa013b8103570239e73f13993a0f44b7270b444d611e8c899aab7b

See more details on using hashes here.

File details

Details for the file gist_backup-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: gist_backup-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.12

File hashes

Hashes for gist_backup-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7e334bd5393e3787815a4550605b9b7e520ca32dd3e0bb0ad4cba790fed71ab0
MD5 039e54b8d5e1d67bd85f8e6443b0291b
BLAKE2b-256 2f70352ceabc0a441ef7558aa6ba85c00dca3c31b64948afd7d929efddd3db4a

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