Skip to main content

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

Metadata

Release files for gist-backup 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gist-backup 0.1.2
File Size Uploaded Provenance Actions
gist_backup-0.1.2.tar.gz 5.2 kB Without provenance Details for gist_backup-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gist-backup 0.1.2
File Interpreter ABI Platform Actions
gist_backup-0.1.2-py3-none-any.whl Python 3 none any Details for gist_backup-0.1.2-py3-none-any.whl

Total release size: 10.5 kB

Release files / gist_backup-0.1.2.tar.gz

Download URL gist_backup-0.1.2.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
33c43f9a04fef42910081512c2a0541605be7505d1edf0c7cc7ca18201cee6a8
BLAKE2b-256 checksum
How to use checksums
e8ed4819495c1a4df06596bb98cb961c3c8881f80501751285a827be9f571816
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Release files / gist_backup-0.1.2-py3-none-any.whl

Download URL gist_backup-0.1.2-py3-none-any.whl
Size 5.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
798feaf4391f8d9c51206351735fc49d13370719d874e68aeb045926947ac21b
BLAKE2b-256 checksum
How to use checksums
c57b46544d8ce842a4882637c63512c100b9904797542bd6f9492786e5f9676a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.12

Security for gist-backup 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page