What is this script?
This is a small script to send yourself an email of your TrueNAS Configuration Files each time the script is run.
This scripts works on both CORE and SCALE.
- Download the file
truenas_config_backup.txt - Rename the file to
truenas_config_backup.sh - Place this file in any directory you want, I suggest your "scripts" directory if you created one.
- Edit the script, update the three values identified above.
- Open a Shell window as
rootand run the command./truenas_config_backup.shto launch the script. - You should have an email if all goes well.
- Open the .tar file attachment and verify you can locate the two files
freenas-v1.dbandpwenc_secret. - Create a CRON Job to run this script as frequently as you desire. This depends on how often you change your configuration.
- If you must use these files, extract them to your local computer so you can upload them using the TrueNAS GUI.
Change the three variables below as desired.
- Email - YOU MUST DO THIS
If you would like to also maintain a copy of the config file on the server:
- Set TrueNASConfigBackupSave from "no" to "yes".
- Set TrueNASConfigBackupLocation to a complete path, ex. "/mnt/mypool/backup_scripts/" or "/mnt/config_backups/".
Run the script from CRON. Below are possible options for user and the command line, the accounts must be setup correctly, root is the one that will work for certain.
- User
rootcd /mnt/mypool/scripts && ./config_backup.sh - User
truenas_admincd /mnt/mypool/scripts && sudo ./config_backup.sh - User
truenas_adminsudo ./mnt/mypool/scripts/config_backup.sh - User
truenas_admincd /mnt/mypool/scripts/ && sudo ./config_backup.sh
This script utilized the sendemail.py script by @oxyde (on GitHub) by downloading
the python script if it does not already exist in the running directory.
If this is a TrueNAS CORE system, one line will be modified to allow the use of
the midclt command. This change is not required if you are using TrueNAS SCALE.
You must have root type privledges to access the two required configuration files.