Backup config file every night automatically!

AleksB

Dabbler
Joined
Jun 26, 2014
Messages
17
Here is how I do my automated backup jobs in the /etc/crotnab:

Code:
0 0 * * * root  tar -cvf "/mnt/backup/freenas/$(date +%Y.%m.%d)_$HOST_$(cat /etc/version | cut -d' ' -f1).tar" -C /data freenas-v1.db pwenc_secret geli/
 

fahadshery

Contributor
Joined
Sep 29, 2017
Messages
179
@AleksB Could you explain a little what it does? I want to take auto config backups of my FreeNas including Password seed. Would this work? How do I set it up? thanks
 

AleksB

Dabbler
Joined
Jun 26, 2014
Messages
17
It backups your:

* Config file - freenas-v1.db
* pwnenc_secret
* geli keys

into /mnt/backup/FreeNAS/2020.06.25_hostname_12.3U1.tar file.

And this happens daily at midnight.
 

fahadshery

Contributor
Joined
Sep 29, 2017
Messages
179
@AleksB jus to confirm (Sorry for being thick) it is the same config backup we do via: System -> General in the FreeNas GUI?
 

AleksB

Dabbler
Joined
Jun 26, 2014
Messages
17
This forum software capitalizes freenas when needed and when not. wtf? correct use freenas-v1.db, where free nas are small letters.
 

Attachments

  • screenshot_2020.06.25_104245.png
    screenshot_2020.06.25_104245.png
    446.9 KB · Views: 256

AleksB

Dabbler
Joined
Jun 26, 2014
Messages
17
I realized, not everyone wants to edit /etc/crontab file, so here is how you do it through the GUI:

screenshot_2020.06.25_104558.png
 

fahadshery

Contributor
Joined
Sep 29, 2017
Messages
179
@AleksB thanks for details. I am getting the following error:
Code:
Sorry, user root is not allowed to execute '/usr/bin/tar -cvf /mnt/raid2TB/FreeNas_Configs/2020.06.25_FreeNAS-11.3-U2.1.tar -C /data FreeNAS-v1.db pwenc_secret geli/' as root on freenas.local.
 

Spearfoot

He of the long foot
Moderator
Joined
May 13, 2015
Messages
2,478
@AleksB thanks for details. I am getting the following error:
Code:
Sorry, user root is not allowed to execute '/usr/bin/tar -cvf /mnt/raid2TB/FreeNas_Configs/2020.06.25_FreeNAS-11.3-U2.1.tar -C /data FreeNAS-v1.db pwenc_secret geli/' as root on FreeNAS.local.
Just use my new, improved configuration backup script. :)
It now includes the password secret seed file:

 

AleksB

Dabbler
Joined
Jun 26, 2014
Messages
17
@AleksB thanks for details. I am getting the following error:
Code:
Sorry, user root is not allowed to execute '/usr/bin/tar -cvf /mnt/raid2TB/FreeNas_Configs/2020.06.25_FreeNAS-11.3-U2.1.tar -C /data FreeNAS-v1.db pwenc_secret geli/' as root on FreeNAS.local.

Where are you getting this error from?
 

fahadshery

Contributor
Joined
Sep 29, 2017
Messages
179
This is how I fixed it:
Code:
tar -cvf /mnt/raid2TB/freenas_configs_backup/"$(date +%Y_%m_%d)_$HOST_$(cat /etc/version | cut -d' ' -f1).tar.gz" -C /data freenas-v1.db pwenc_secret
 

fahadshery

Contributor
Joined
Sep 29, 2017
Messages
179
@AleksB I had to remove geli/ at the end because it errors out:

Code:
tar: geli: Cannot stat: No such file or directory
 
Joined
Oct 24, 2023
Messages
1
For example, what if md5 is moved from /sbin to /usr. Your code suddenly won't work. What if the /bin/cp moves? Weird things like that *may* move in FreeBSD 10 (and therefore FreeNAS 10) because of the
This is FreeBSD, not linux. Directories mean something and the developers consider how their actions affect people. I don't think there's anything more simple than basic scripting that relies on the existence of 'cp' and 'md5' instead of gigabytes of unstable dependencies. Thankfully, it seems there's still an operating system developed by people that understand that.
 

Ericloewe

Server Wrangler
Moderator
Joined
Feb 15, 2014
Messages
20,194
Was that really worth reviving a long-dead thread? A throwaway comment from 2014 (nine years ago) that came about because someone hardcoded a few executable paths instead of relying on $PATH?

And for any readers that might have missed it: this is FreeBSD and Linux. The year is 2023 and TrueNAS Scale exists and some people really like it, and that's not in any way a bad thing.
 
Top