snickasaurus
Dabbler
- Joined
- Feb 19, 2012
- Messages
- 18
Hello all. I've been playing around with my commandlinefu to keep it strong. There are definitely some great scripts out here to keep an eye on one's FreeNAS box. I just wanted to share this one in hopes someone might like it or a scripting/security guru could tell me how dumb of an idea it is.
First and foremost this requires adding biabam to your FreeNAS install. If you don't like adding tools to your FreeNAS then please disregard this post!
To add biabam, get to a root shell on FreeNAS and do the following:
For FreeNAS based on FreeBSD 10
For FreeNAS based on FreeBSD 11 (untested as I'm still on FreeNAS-9.10.2-U6)
The tool will be located in /usr/local/bin. Now on to the script. I have my running as a cron job every other day.
First and foremost this requires adding biabam to your FreeNAS install. If you don't like adding tools to your FreeNAS then please disregard this post!
To add biabam, get to a root shell on FreeNAS and do the following:
For FreeNAS based on FreeBSD 10
Code:
wget http://pkg.freebsd.org/FreeBSD:10:amd64/latest/All/biabam-0.9.7_2.txz pkg install biabam-0.9.7_2.txz rehash
For FreeNAS based on FreeBSD 11 (untested as I'm still on FreeNAS-9.10.2-U6)
Code:
wget http://pkg.freebsd.org/FreeBSD:11:amd64/latest/All/biabam-0.9.7_2.txz pkg install biabam-0.9.7_2.txz rehash
The tool will be located in /usr/local/bin. Now on to the script. I have my running as a cron job every other day.
Code:
#!/bin/sh logfile="/tmp/email-config-backup.log" if [ "$(sqlite3 /data/freenas-v1.db "pragma integrity_check;")" = "ok" ] then ### Send config backup ### mkdir /tmp/backupConfig cd /tmp/backupConfig || return cp /data/freenas-v1.db /tmp/backupConfig/ md5 freenas-v1.db > freenas-v1.md5 sha256 freenas-v1.db > freenas-v1.sha256 tar -cf config.tar ./freenas-v1.db ./freenas-v1.md5 ./freenas-v1.sha256 mv config.tar FreeNASDatabase.tar # Edit here to your liking echo "See attached .TAR file." | /usr/local/bin/biabam FreeNASDatabase.tar -s "FreeNAS Database Backup" YOUREMAILADDRESS cd - rm -R /tmp/backupConfig else
Last edited: