CLI tool for backing up TrueNAS configurations.
Project description
TrueNAS Backup Tool
A CLI tool for backing up TrueNAS configurations using the TrueNAS API. It initiates a config download via the API, saves the backup as a .tar.gz file, and manages retention by limiting the number of kept backups.
Features
- Authenticates with TrueNAS using API key.
- Downloads configuration backups with optional inclusion of secretseed and root authorized keys.
- Saves backups to a specified directory (default: system temp directory, e.g., /tmp on Unix, %TEMP% on Windows).
- Automatic retention management to keep only the specified number of recent backups.
- Cross-platform compatible.
- CLI commands:
runto perform a backup.
Usage
No installation required. The tool can be run directly with uvx (requires uv installed):
uvx truenas-backup --url truenas.local --api-key your-api-key
Note: For uvx, provide options directly; .env files are not loaded automatically.
Optionally, export environment variables directly:
export TRUENAS_URL=truenas.local
export TRUENAS_API_KEY=your-api-key
export VERIFY_SSL=false
export MAX_BACKUPS=5
export SECRETSEED=false
export ROOT_AUTHORIZED_KEYS=false
Perform a Backup
truenas run
This performs a backup using environment defaults (from exports or .env).
With options (overrides env vars):
truenas run --url truenas.local --api-key your-api-key --backup-dir /path/to/backups --max-backups 10 --secretseed --verify-ssl
Options:
--url TEXT: TrueNAS URL (overridesTRUENAS_URL).--api-key TEXT: API key (overridesTRUENAS_API_KEY).--verify-ssl / --no-verify-ssl: Verify SSL (overridesVERIFY_SSL).--max-backups INTEGER: Max backups to keep (overridesMAX_BACKUPS).--secretseed / --no-secretseed: Include secretseed (overridesSECRETSEED).--root-authorized-keys / --no-root-authorized-keys: Include root keys (overridesROOT_AUTHORIZED_KEYS).--backup-dir TEXT: Directory to save backups (default: system temp dir).
Output example:
Backup completed: {'filename': '/tmp/truenas-backup-20251023-232000.tar.gz', 'size': 123456, 'backups_kept': 5}
Docker
The project includes a Dockerfile for containerized deployment.
Build the image:
docker build -t truenas-backup .
Run with environment and volume mount:
docker run -it --env-file .env -v /host/backups:/app/backups truenas-backup python main.py run --backup-dir /app/backups
For scheduled runs, use cron inside the container or host cron.
Development
- Linting:
uv run ruff check . - Run tests: (Add tests as needed)
License
MIT License - see LICENSE for details.
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 truenas_backup-1.0.0.tar.gz.
File metadata
- Download URL: truenas_backup-1.0.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
79a9ebf4672b7095792f4e89a3b6302a220ad847622035e7a1d82d2a4983c0ff
|
|
| MD5 |
58a72c7e2f72d6511079cc82bc063f0b
|
|
| BLAKE2b-256 |
e8c7b9abc35ec29173126b00c2503878d19125d994668857503ee60772a343bb
|
Provenance
The following attestation bundles were made for truenas_backup-1.0.0.tar.gz:
Publisher:
publish-to-pypi.yml on theLastOfCats/truenas-backup
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
truenas_backup-1.0.0.tar.gz -
Subject digest:
79a9ebf4672b7095792f4e89a3b6302a220ad847622035e7a1d82d2a4983c0ff - Sigstore transparency entry: 635255269
- Sigstore integration time:
-
Permalink:
theLastOfCats/truenas-backup@d23a7b00fb13d5f48a5f213ee192ef58ef498b29 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/theLastOfCats
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@d23a7b00fb13d5f48a5f213ee192ef58ef498b29 -
Trigger Event:
release
-
Statement type:
File details
Details for the file truenas_backup-1.0.0-py3-none-any.whl.
File metadata
- Download URL: truenas_backup-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9a59e3692bd509792320fb08eb1e250568a80ccb6ed62a3fc4b18bb093f65495
|
|
| MD5 |
9293aa00863d759dda3efac6c13f388c
|
|
| BLAKE2b-256 |
8983ad634b3b075b6aef8cc219c0deff40f038ce09c5ede8b648f6116310a72d
|
Provenance
The following attestation bundles were made for truenas_backup-1.0.0-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on theLastOfCats/truenas-backup
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
truenas_backup-1.0.0-py3-none-any.whl -
Subject digest:
9a59e3692bd509792320fb08eb1e250568a80ccb6ed62a3fc4b18bb093f65495 - Sigstore transparency entry: 635255305
- Sigstore integration time:
-
Permalink:
theLastOfCats/truenas-backup@d23a7b00fb13d5f48a5f213ee192ef58ef498b29 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/theLastOfCats
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@d23a7b00fb13d5f48a5f213ee192ef58ef498b29 -
Trigger Event:
release
-
Statement type: