Back up the config via script?

jonf

Dabbler
Joined
Jan 28, 2021
Messages
18
I've been looking into ways in which I could schedule a backup of the TrueNAS config with a script. Looking into the tar file I got manually from the server (including the secret seed) I see the files in question, which I discovered are stored in the /data directory in TrueNAS. At first I thought, in theory, I could just use the tar command to create a new archive containing both files and use some of the steps here to upload it to Google Drive. However, on closer inspection of the tar file in 7-Zip, I noticed there's a couple of directories called "." with files inside called "@PaxHeader".

What are these? Where do they come from? Are these essential for TrueNAS to recognise the tar file as a proper config to be restored via the GUI, or will it work without them?
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399

This is an extension to the TAR specification. Leave them alone.
 

Samuel Tai

Never underestimate your own stupidity
Moderator
Joined
Apr 24, 2020
Messages
5,399
Also, forum search is your friend.

 

jonf

Dabbler
Joined
Jan 28, 2021
Messages
18
Also, forum search is your friend.


Interesting. This didn't come up in my original search, I'll try it out tomorrow. Thanks.
 

jonf

Dabbler
Joined
Jan 28, 2021
Messages
18
OK on closer inspection of that script it looks like it copies the 'freenas-v1.db' file into a temp directory on the system drive and writes a log in the same location to say what happened. I was hoping it would also copy the 'pwenc_secret' file but I don't see any reference to it in the script. I don't know really Python so I wouldn't know how to add that file to the process (at least without breaking something :tongue:).
 

jonf

Dabbler
Joined
Jan 28, 2021
Messages
18
I've just done some further testing with TrueNAS in VirtualBox. I created two virtual machines onto which I would install TrueNAS; the first machine was configured manually once I installed TrueNAS, after which I then ran the following command in the console from the /data directory:

tar -cvf test.tar freenas-v1.db pwenc_secret

I pulled the tar file onto my desktop via Filezilla. I then installed TrueNAS onto the second VM and configured the network settings in the console before going into the web GUI. From there I uploaded my tar file as the config to be restored, after which it rebooted a couple of times and seemed to work without any apparent ill effects.

I think this will make it easier in the future to create a tar (which I can then sync to the cloud using Cloud Credentials to keep it off the server itself) that I can simply upload via the web GUI in order to restore my config if/when needed, rather than manually copying the files via SFTP or something. Unless the @PaxHeader files added to the tar by the web GUI process include extra hidden data that TrueNAS might need for later?
 
Top