Skip to content

Instantly share code, notes, and snippets.

@mezhgano
Last active September 6, 2025 14:53
Show Gist options
  • Save mezhgano/bfc19f4711830af8ace87745ab4192f1 to your computer and use it in GitHub Desktop.
Save mezhgano/bfc19f4711830af8ace87745ab4192f1 to your computer and use it in GitHub Desktop.
Backup TrueNAS config
#!/bin/bash
# Use exact same file naming as GUI exports
BACKUP_NAME=`hostname -s`-`cat /etc/version | cut -d ' ' -f 1`-`date +%Y%m%d%H%M%S`
# Change to your desired path
BACKUP_LOCATION="/mnt/some_pool/some_dataset/some_folder"
# Include secret seed as well
tar cf "$BACKUP_LOCATION"/$BACKUP_NAME.tar -C /data/ freenas-v1.db pwenc_secret
# Remove backups older than 365 days
find "$BACKUP_LOCATION"/*.tar -mtime +365 -exec rm {} +
@mezhgano
Copy link
Author

mezhgano commented Sep 6, 2025

  1. Download the file and put it somewhere in TrueNAS root folder, like here:
    /root/script/backup_config.sh
  2. Make it executable:
    chmod u+x backup_config.sh
  3. Add task in GUI:
    Tasks > Cron Jobs > Add
Screenshot 2025-09-06 17-52-22 TrueNAS_-_192 168 1 33_-_Thorium

Tested in TrueNAS-13.0-U6.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment