Simple Backup and Restore Script

Status
Not open for further replies.

gmontalvo

Dabbler
Joined
Sep 4, 2012
Messages
18
Hi Guys,

This is my first post, so I will offer some of my background. From the start, I loved Windows Home Server. It was not perfect, but there were many things to like. In fact, I liked the platform so much I wrote software for it (shameless plug: www.keepvault.com). Since Microsoft - in its infinate wisdom - has decided to end of life the project, I have become a huge fan of FreeNAS. I have replaced my WHS box with FreeNAS and love it!

Now ... although I love the robust and rich features offered by ZFS, RAID like solutions provide data availability and not data protection. I wanted a simple backup solution, and put together the script below. I'm offering the script here in a hope that it helps someone.

Greg

NOTE: /mnt/storage and /mnt/backup are two different pools running on separate hardware.

Code:
#!/bin/sh

# Simple script to backup data from BACKUP_SRC to BACKUP_DST
#
# this can be any drive attached to your FreeNAS box ...
# ... internal drive(s), external USB drive(s), external SATA drives(s)

# Backup source
BACKUP_SRC=/mnt/storage/

# Backup destination -- DO NOT include the trailing slash
BACKUP_DST=/mnt/backup

rsync -aq -HAX --delete $BACKUP_SRC $BACKUP_DST

# For a seven day cyclical backup, remove the comment from the line 'DAY=options' and
# set the preferred directory name format 'Monday, etc or Mon, etc'
# A = long day name   (i.e. Monday, Tuesday, ... Sunday)
# a = short day name  (i.e. Mon, Tue, ... Sun)
# This will create a daily backup directory (i.e. backup/Sat backup/Sun)
# DAY=/`date +%a`
#
# rsync -aq -HAX --delete $BACKUP_SRC $BACKUP_DST$DAY

# In the event of a drive failure:
#
#   1. Replace failed hardware.
#   2. Recreate datasets and set appropriate permission
#   3. Reverse paths in this script and re-run it

# end 
 
Status
Not open for further replies.
Top