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.0.tar.gz (5.0 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.0-py3-none-any.whl (2.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gist_backup-0.1.0.tar.gz
  • Upload date:
  • Size: 5.0 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.0.tar.gz
Algorithm Hash digest
SHA256 056de202f3c7101a87da935c69be936c238fe9e64318c9171dba5fa4e0c3f3a6
MD5 9c93bf9da821edab38a69279221b5422
BLAKE2b-256 ef60be1be1a296f105a1f7a6c2b87cadda2cdf7a6bf10d4280ed231295e15220

See more details on using hashes here.

File details

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

File metadata

  • Download URL: gist_backup-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.1 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c7c6b25b12d572be2358b30407b93e069c64cfd8a07fc8ce06e1cc78985e982d
MD5 62fcedfd895de850e75dc795203dd862
BLAKE2b-256 31efb89d768b097ee19989d7ac520defa96a8ad6e9f2c711bc56dea2224efbe4

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