{"id":31217065,"url":"https://github.com/crypdick/truenas-settings-auto-backup","last_synced_at":"2026-07-09T15:31:34.760Z","repository":{"id":313753908,"uuid":"1052499501","full_name":"crypdick/truenas-settings-auto-backup","owner":"crypdick","description":"Script to automatically backup TrueNAS configs","archived":false,"fork":false,"pushed_at":"2026-06-13T23:37:11.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-14T01:19:45.261Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crypdick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-08T06:25:52.000Z","updated_at":"2026-06-13T23:37:15.000Z","dependencies_parsed_at":"2025-09-12T11:18:23.971Z","dependency_job_id":null,"html_url":"https://github.com/crypdick/truenas-settings-auto-backup","commit_stats":null,"previous_names":["crypdick/truenas-settings-auto-backup"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/crypdick/truenas-settings-auto-backup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crypdick%2Ftruenas-settings-auto-backup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crypdick%2Ftruenas-settings-auto-backup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crypdick%2Ftruenas-settings-auto-backup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crypdick%2Ftruenas-settings-auto-backup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crypdick","download_url":"https://codeload.github.com/crypdick/truenas-settings-auto-backup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crypdick%2Ftruenas-settings-auto-backup/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35304874,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-09T02:00:07.329Z","response_time":57,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-21T13:59:08.004Z","updated_at":"2026-07-09T15:31:34.741Z","avatar_url":"https://github.com/crypdick.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# truenas-settings-auto-backup\nScript to automatically backup TrueNAS configs for Linux systems using the latest TrueNAS JSON-RPC 2.0 WebSocket API.\n\nInspired by https://git.pickysysadmin.ca/eric/truenas-config-backup, which does the same thing but uses PowerShell.\n\nNotes:\n- TrueNAS REST API is deprecated and being removed; this script uses the recommended WebSocket JSON-RPC API and the official client. See: [TrueNAS API Reference](https://www.truenas.com/docs/scale/api/) and [truenas/api_client](https://github.com/truenas/api_client).\n\n## Usage\n\n### Setup\n- Optional: create a venv and install dependencies:\n  \n  ```bash\n  python3 -m venv .venv\n  . .venv/bin/activate\n  pip install -r requirements.txt\n  ```\n\n### Provide API key\n- Create a non-expiring API key in TrueNAS. Store it securely.\n- Preferred: save it to a root-only file (example: `/root/.truenas_api_key`).\n- Or export it as an environment variable `TRUENAS_API_KEY`.\n\n### Run\n- From the TrueNAS box itself (self-signed certs common):\n  \n  ```bash\n  TRUENAS_API_KEY=\"$(cat /root/.truenas_api_key)\" python3 backup.py \\\n    --host 127.0.0.1 \\\n    --out-dir /mnt/pool/backups/truenas \\\n    --include-secrets \\\n    --no-verify-tls\n  ```\n\n- From another Linux host with a valid certificate:\n  \n  ```bash\n  export TRUENAS_API_KEY=your_api_key_here\n  python3 backup.py \\\n    --host https://truenas.example.com \\\n    --out-dir /backups/truenas \\\n    --include-secrets\n  ```\n\nNotes:\n- `--include-secrets` includes `secretseed` in the exported config.\n- `--no-verify-tls` is useful for self-signed certs. Omit if you trust the CA.\n- `--retention N` keeps the latest N backups (default 14).\n\n## Run periodically on TrueNAS (Cron Job)\n\nYou can schedule this script directly on your TrueNAS system using a Cron Job.\n\n### TrueNAS SCALE\n- Open: System Settings → Advanced → Cron Jobs → Add\n- Set:\n  - User: root (or a service account with API access)\n  - Schedule: as desired (e.g., Daily at 03:00)\n  - Command (example):\n    - If your API key is stored in a root-only file at `/root/.truenas_api_key`:\n      \n      ```bash\n      TRUENAS_API_KEY=\"$(cat /root/.truenas_api_key)\" /usr/bin/python3 /mnt/pool/scripts/truenas-settings-auto-backup/backup.py \\\n        --host 127.0.0.1 \\\n        --out-dir /mnt/pool/backups/truenas \\\n        --include-secrets\n      ```\n      \n\n- Enable the job and click Run Now to test.\n\nNotes (SCALE):\n- Python path is typically `/usr/bin/python3`.\n- Place the script in a dataset, e.g., `/mnt/pool/scripts/...`, and ensure execute permissions.\n\n### TrueNAS CORE\n- Open: Tasks → Cron Jobs → Add\n- Set:\n  - User: root (or a service account with API access)\n  - Schedule: as desired\n  - Command (example):\n    \n    ```bash\n    TRUENAS_API_KEY=\"$(cat /root/.truenas_api_key)\" /usr/local/bin/python3 /mnt/pool/scripts/truenas-settings-auto-backup/backup.py \\\n      --host 127.0.0.1 \\\n      --out-dir /mnt/pool/backups/truenas \\\n      --include-secrets\n    ```\n- Enable the job and click Run Now to test.\n\nNotes (CORE):\n- Python path is typically `/usr/local/bin/python3`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrypdick%2Ftruenas-settings-auto-backup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrypdick%2Ftruenas-settings-auto-backup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrypdick%2Ftruenas-settings-auto-backup/lists"}