OK, here goes with some very bare-bones instructions on how to use my scripts. Obviously, I will not take responsibility for any resulting data loss. Please note, I realized there was no clear benefit to running this from a jail, so I'm assuming you're not, because it makes the instructions much simpler. If you want to run this from a jail, you'll have to install the underlying software (python, rsync, mDNSResponder etc) and figure out how to automate it if you think that's important.
- Create a dataset for your rsync backups.
- Inside, create a folder or child dataset for each client user’s backup repository.
- Create a suitable rsync.exclude inside each client’s repository.
- Create a read-only share to use for restore (per client if privacy is a concern).
- If you don’t yet have an SSH key pair for your FreeNAS root user, login as root and run ssh-keygen. Press enter 3 times to accept the default location and no passphrase.
- Copy /root/.ssh/id_rsa.pub to the shared folder(s).
- For each client user, from the client machine, connect to the read-only share and copy or append id_rsa.pub to ~/.ssh/authorized_keys.
- Test SSH from FreeNAS to each client. If you have to enter a password, you did it wrong.
- Place backup.py and prune.py in a suitable location. The parent dataset from step 1 is as good a place as any. Make them executable.
- Create a startup shell script to launch backup.py for each client.
- Run the startup shell script from the command-line. Optionally, set up a task to launch it as a Post Init script.
The backup script will launch rsync, pulling from the client and writing to a folder named pending. If the backup completes successfully, pending will be renamed with the date- and time-stamp of when the backup completed. The next backup will be attempted one hour after the previous one completes, regardless of success or failure.
After a successful backup, the backup script will launch prune.py to prune existing backups, keeping up to 24 hours of hourly backups, up to 4 weeks of daily backups, and up to 1 year of weekly backups.
Inside each backup folder, you will find rsync.log, which itemizes the rsync transfer that created it, and prune.log, which shows which backups were retained and which were pruned after it was completed.
My startup shell script, located in the same folder as the backup and pruning scripts, looks like this:
Code:
./backup.py sue@media-mini:/Users media-mini &
./backup.py rob@robs-mini:/Users robs-mini &
./backup.py rob@robs-air:/Users robs-air &
./backup.py sue@sues-air:/Users sues-air &
The syntax is: <path-to-backup-script> <user>@<machine>:<source folder> <path-to-repository>. The trailing ampersand on each line means "launch this as a background task and return". Therefore, I'm backing up the Users folder from each client machine to a folder on FreeNAS with the same name as the client machine. The user in each case has permission to read everything inside the Users folder. If that's not the case for you, you will need to backup more selectively, or create another user on the client machine that can access everything you want to backup.
Backup script (backup.py):
http://pastebin.com/RqECqwgU
Pruning script (prune.py):
http://pastebin.com/jUmmWpZy
Example rsync.exclude for OS X:
http://pastebin.com/MaTwEwP3
NOTE 1: the backup script assumes that the pruning script is called "prune.py", and that both are in the same folder.
NOTE 2: I had trouble with long machine names not being resolved by Bonjour on FreeNAS. For example, my laptop used to be called "robs-macbook-air", but FreeNAS couldn't find it via Bonjour, so I renamed it to "robs-air". I don't know if it was the length of the name or the second hyphen that caused the problem.
NOTE 3: Do NOT attempt to backup more than one source to the same repository.
Please let me know if you discover any glaring defects. Better still, let me know if you find it useful.