Automatic Configuration Backup

Status
Not open for further replies.

Derek Humes

Dabbler
Joined
Feb 22, 2016
Messages
44
Hello, I have recently used another thread I found to setup an automatic copy of my FreeNAS configuration to one of my datasets so that in the event of a boot device failure, I have a copy of the configuration.

This is the command that I have used to test this. This command works if I issue it manually in the shell as root:
cp /data/freenas-v1.db "/mnt/volume/dataset/`date \+%Y\%m\%d`_`cat /etc/version | cut -d'-' -f2`_`cat /etc/version | cut -d'-' -f4`.db"

This creates a copy of the freenas-v1.db file with the date and version in the filename.

I have setup a Cron job on my FreeNAS GUI to run this command nightly at 10PM EST. However, each night I am receiving the below error message in email, and a copy of the configuration is NOT created.


Syntax error: EOF in backquote substitution
Syntax error: Error in command substitution


I have tried some online syntax checker tools for my command to determine why these errors are occurring, but I have not had any luck. My experience with Unix command line shell is very minimal, but slowly growing.

My machine build is FreeNAS-9.10.2-U1 (86c7ef5).

Any assistance with this would be greatly appreciated. Thank you!
 

Derek Humes

Dabbler
Joined
Feb 22, 2016
Messages
44
This is it, thank you for the quick response - working now!

FYI I also had to edit in the script the last section to use field -F3 instead of -F4.
 

wblock

Documentation Engineer
Joined
Nov 14, 2014
Messages
1,506
That can be simplified:
cp /data/freenas-v1.db "`date '+/mnt/volume/dataset/%Y-%m-%d'`_`cut -d'-' -f2,3 /etc/version`.db"
 

Derek Humes

Dabbler
Joined
Feb 22, 2016
Messages
44
Thanks for letting me know. It is working OK right now with how I have it, so I'm not touching it! Thank you though...
 

BBarker

Contributor
Joined
Aug 7, 2015
Messages
120
Out of curiosity, did you edit your original post to reflect the properly working script?
 
Status
Not open for further replies.
Top