cp /data/freenas-v1.db /mnt/Volume2/db-backups/`date +%Y%m%d%H%M`.db
Not sure who you're asking... but I'll take a stab at answering.Question:
Why would you make a cron job to run a script file instead of just making the cron job run the command itself?
Ex: Paste (in my case)
Code:cp /data/freenas-v1.db /mnt/Volume2/db-backups/`date +%Y%m%d%H%M`.db
Under "command" in the cron job config. It seems to do the same thing for me
cp: (d989edd)_.db is not a directory
cp /data/freenas-v1.db /mnt/Ark/Jim/configbak/`date +%Y%m%d`_`cat /etc/version | cut -d'-' -f2`_`cat /etc/version | cut -d'-' -f4 | sed -e 's/ /_/'`.db
cp /data/freenas-v1.db /mnt/volume1/.ConfigBackups/`date +%Y%m%d`_`cut -d' ' -f1 /etc/version|cut -d'-' -f2`.db
20160807_9.10.1.db
Thank you, that works.It should also NOT break every time the /etc/version changes.
@Kam, the issue you cited has to do with backing up the configuration database locally, whenever changes are made to the system.Where is difference between such own backups and following freenas feature?
Feature #4821 Automatic configuration backup
It seems that freenas automatically makes backup of config db to .system dataset, mounted under /var/db/system/configs-xxxx directory.
@Kam, the issue you cited has to do with backing up the configuration database locally, whenever changes are made to the system.
What we're doing here is copying the FreeNAS configuration file off-machine for safekeeping. This allows for completely restoring an existing FreeNAS server if it should fail in any way, or burn in a house fire, or what have you.
Doooh! You're right, these scripts also just copy the configuration file locally. I've configured my system to rsync mine off-machine shortly after this script runs. I got the two separate processes muddled.Most of scripts posted here makes backup to local zfs pool.
But of course remote offsite backup makes sense. Unfortunatelly with this new Feature it makes backup to .system dataset, which seems is not possible to replicate or rsync to second location using gui.
A. I have no idea how to get anything out of the system dataset. That's a black box to me. I know how to access my saved config files.Most of scripts posted here makes backup to local zfs pool.
But of course remote offsite backup makes sense. Unfortunately with this new feature it makes backup to .system dataset, which seems is not possible to replicate or rsync to second location using gui.
cp /data/freenas-v1.db /mnt/volume/backups/config-`hostname`-`cat /etc/version | awk -F'[- ]' '{print $2 "_" $3}'`-`date "+%Y%m%d%H%M"`.db && find /mnt/volume/backups/* -mtime +90 -type f -delete
scp /data/freenas-v1.db username@backup_server_fqdn:/mnt/volume/backups/config-`hostname`-`cat /etc/version | awk -F'[- ()]' '{print $2 "_" $4}'`-`date "+%Y%m%d%H%M"`.db
Huh?I don't know what I was thinking but this will not work because you cannot send a password in this script and I do not believe FreeNAS allows us to use SSH with RSA keys.
Huh?
Ah, now I understand! FreeNAS is based on FreeBSD, and you can set it up w/ RSA keys for password-less access via SSH. That ought to let you use SCP. Or if not, you could definitely use rsync; I do all the time.I should have worded that better, using SCP in a script will not work because you cannot pass the password to the command. So the script for using SCP will not work BUT the first script will for making a backup to a local volume.
Sorry for the confusion!
cp /data/freenas-v1.db /mnt/WDVolume_A/Data/Config_Backups/backups/`date \+%Y%m%d`_`cat /etc/version | cut -d'-' -f2`_`cat /etc/version | cut -c21-32`.db
cp: (d989edd)_edd).db is not a directory
Yeah, I think the parentheses and/or spaces are causing problems. Try my script located earlier in this thread, it strips parentheses and replaces the spaces with a '-'.Good morning, after the last update: (FreeNAS-9.10.1 (d989edd)) i have occurred in a problem with the automatic backup of my configuration... This is my script:
Code:cp /data/freenas-v1.db /mnt/WDVolume_A/Data/Config_Backups/backups/`date \+%Y%m%d`_`cat /etc/version | cut -d'-' -f2`_`cat /etc/version | cut -c21-32`.db
And this is the error:
Code:cp: (d989edd)_edd).db is not a directory
I sure that is something related to the name of the configbackup name but i can't solve it... Someone can help?