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:
- Go to https://github.com/settings/tokens
- Generate a new token (classic or fine-grained) with the
gistscope - 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
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 gist_backup-0.1.2.tar.gz.
File metadata
- Download URL: gist_backup-0.1.2.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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33c43f9a04fef42910081512c2a0541605be7505d1edf0c7cc7ca18201cee6a8
|
|
| MD5 |
5ba2cb6c82fe01237fe104335302c6ae
|
|
| BLAKE2b-256 |
e8ed4819495c1a4df06596bb98cb961c3c8881f80501751285a827be9f571816
|
File details
Details for the file gist_backup-0.1.2-py3-none-any.whl.
File metadata
- Download URL: gist_backup-0.1.2-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
798feaf4391f8d9c51206351735fc49d13370719d874e68aeb045926947ac21b
|
|
| MD5 |
bf236ca424bba5d504051b3f29f59e6b
|
|
| BLAKE2b-256 |
c57b46544d8ce842a4882637c63512c100b9904797542bd6f9492786e5f9676a
|