It shows when I do 'zfs list', but I can't navigate to it or see it with ls -la or find it. What am I doing wrong?It's in the .system hidden dataset ;)
[jim@Tabernacle ~]$ cd /mnt/Ark/.system -bash: cd: /mnt/Ark/.system: No such file or directory [jim@Tabernacle ~]$ ls -la /mnt/Ark total 159 drwxr-xr-x 10 root wheel 10B Jul 13 2015 ./ drwxr-xr-x 4 root wheel 120B Jan 20 14:12 ../ drwxr-xr-x 9 root wheel 12B Feb 8 2015 .freenas/ drwxrwx--- 11 jim staff 15B Jan 31 15:23 Attic/ drwxr-x--- 7 jim wheel 16B Feb 6 07:45 Jim/ drwxr-x--- 11 jim wheel 15B Feb 6 06:16 Media/ drwxr-xr-x 6 shuling staff 8B Dec 29 12:02 Shuling/ drwxrwx--- 4 jim nogroup 7B Feb 6 12:40 TM-Jim/ drwxrwx--- 4 shuling staff 7B Feb 5 18:33 TM-Shuling/ drwxr-xr-x 10 root wheel 10B Dec 12 14:57 jails/ [jim@Tabernacle ~]$ sudo find /mnt/Ark -name ".system" -print Password: [jim@Tabernacle ~]$
hey all
thanks for everyone's contributions. Thanks to more than a couple of people on here (@cyberjock @joeschmuck etc) I now have my config file backuped up safely overnight...I combined some of the commands and come up with a readable date along with there version number being attached to the file name:
cp /data/freenas-v1.db "/mnt/tank/`date \+%c`_`cat /etc/version | cut -d'-' -f2`.db" && find /mnt/tank/ -mtime +90 -exec rm {} \;
this command keeps the files for 90 days and then deletes them and I think all is working fine but I am getting a slight issue with permissions.
I get an error from the cron job saying "/mnt/tank/ permission denied" I can confirm that it is saving the .db file correctly but it doesn't seem to be able to execute the second part of the command about scanning to delete anything older than 90 days.
Any ideas? here are my permission on the said directory:
drwxrwxrwx
(as you can see i even modified the directory to chmod 777) but it still returns the error?
What owner and permissions are configured for this dataset? Just set the owner to be that of the user that is running the backup script and you should be fine.Hello,
Sorry Kevin, you're right. I changed some parameters in the command i posted above for posting on the internet.
the second part of the command does read:
find /mnt/tank/dbbackups -mtime +90 -exec rm {} \;
it seems the permissions on the .db files being generated are not letting the operation delete them if necessary. i just checked the permission on one of the backed up confirmation files and they are:
-rw-r-----
would this be an issue with "setfacl"?
[root@freenas] ~# echo `date \+%c`_`cat /etc/version | cut -d'-' -f2`.db
Sat Feb 20 23:56:30 2016_9.3.db
sorry for probably the simplistic question but I don't see the difference in your revised code. maybe because of the font formatting on the forum but i don't see how you eliminated the spaces.
the dbbackups is just a directory on the dataset owned by root. that is what i don't understand because the cron job is running as root. the permissions for the whole dataset are:
owner:root
group:wheel
#!/usr/bin/env python import os import shutil VERSION_FILE = '/etc/version' DB_FILE = '/data/freenas-v1.db' BACKUP_DIR = '/mnt/storage/backup/freenas_config' version = open(VERSION_FILE, 'r').read().strip() backup_name = '%s.db' % version.replace(' ', '-').replace('(', '').replace(')', '') shutil.copyfile(DB_FILE, os.path.join(BACKUP_DIR, backup_name))
FreeNAS-9.10-STABLE-201603252134-412fb1c.db
/root/bin/dropbox_uploader.sh -f /root/.dropbox_uploader -q upload /mnt/storage/backup/freenas_config FreeNAS/Backups
#!/bin/sh ### Parameters ### logfile="/tmp/config_backup_error.tmp" tarfile="/tmp/config_backup.tar" filename="$(date "+FreeNAS_Config_%Y-%m-%d_%H-%M-%S")" email="email@gmail.com" subject="Config Backup for FreeNAS" if [ "$(sqlite3 /data/freenas-v1.db "pragma integrity_check;")" == "ok" ] then ### Send config backup ### cp /data/freenas-v1.db "/tmp/${filename}.db" md5 "/tmp/${filename}.db" > /tmp/config_backup.md5 sha256 "/tmp/${filename}.db" > /tmp/config_backup.sha256 cd "/tmp/"; tar -cf "${tarfile}" "./${filename}.db" ./config_backup.md5 ./config_backup.sha256; cd - uuencode "${tarfile}" "${filename}.tar" | mail -s "${subject}" "${email}" rm "/tmp/${filename}.db" rm /tmp/config_backup.md5 rm /tmp/config_backup.sha256 rm "${tarfile}" else ### Send error message ### ( echo "To: ${email}" echo "Subject: ${subject}" echo "Content-Type: text/html" echo "MIME-Version: 1.0" echo -e "\r\n" echo "<pre style=\"font-size:14px\">" echo "" echo "Automatic backup of FreeNAS config failed." echo "" echo "The config file is corrupted!" echo "" echo "You should correct this problem as soon as possible." echo "" echo "</pre>" ) >> "${logfile}" sendmail -t < "${logfile}" rm "${logfile}" fi
cp /data/freenas-v1.db /mnt/root-dataset/raid_array/backups/freenas-phys-config/`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/root-dataset/raid_array/backups/freenas-phys-config/`date +%Y%m%d`_`cat /etc/version | cut -d'-' -f2`_`cat /etc/version | cut -d'-' -f4 | cut -d' ' -f1`.db
#!/bin/bash # The source FreeNAS configuration database file: SRC_FILE="/data/freenas-v1.db" # Form the destination filename: DEST_DIR="/mnt/tank/sysadmin/config" DEST_HOST=$(hostname -s) DEST_VERSION=$(cat /etc/version | sed -e 's/ /-/' | sed -e 's/(//' | sed -e 's/)//') DEST_DATE=$(date +%Y%m%d%H%M%S) DEST_FILE="$DEST_HOST"-"$DEST_VERSION"-"$DEST_DATE".db echo "Backup configuration database file: $DEST_FILE" # Copy the source to the destination: cp "$SRC_FILE" "$DEST_DIR"/"$DEST_FILE" # Remove prior versions in the destination directory that are 90 days old or older: $(find "$DEST_DIR" -mtime +90 -name "*.db" -exec bash -c 'rm {}' \;)
DESTFILE=${DESTDIR}/freenas-$(cat /etc/version | cut -d'-' -f2)_$((cat /etc/version | cut -d'-' -f4) | sed 's/\ /_/g')_$(date +%Y%m%d%H%M%S).db