Header Shadow Image


Simple Home Backup Solution

Earlier we've setup our HTPC and Backup and shared it out to our Windows machines, but one thing we did not add in is the backup job.  With the earlier solutions, the backup becomes trivial.  (Anything can become simple as long as the core design is well designed with future simplicity in mind.)  This is fairly simple by most system administrator standards but does assume you do know a bit of scripting to do the job with.  Naturally this can be done even easier so I'll show two options.  First the KSH option for automating this slightly:

 

#!/usr/bin/ksh

MOI=$(basename $0);

CDATE=$(date);

print — "$MOI: ($CDATE): Starting run of $MOI. " >> /var/log/$MOI.log 2>&1;

# TM="YES";
TM="NO";
TARGET="/mnt/HTPCBackupXFS";

for KEY in $( print \
                /mnt/FLASHLexarMedia-32GB-1             \
                /mnt/FLASHLexarMedia-32GB-0             \
                /mnt/FLASHKingstonCenton                \
                /mnt/VGEnt                              \
                /mnt/HTPCFileStorage                    \
        ); do
        [[ $TM == “NO” ]] && {
                print — "$MOI: Running rsync -avc –progress $KEY $TARGET:";
                rsync -avc –progress $KEY $TARGET;
        } || {
                print — "$MOI: Will run rsync -avc –progress $KEY $TARGET .";
        }
done >> /var/log/$MOI.log 2>&1;

Next we will edit the crontab to add in the job (Type crontab -e on the command line to edit the crontab file):

[root@mbpc-pc mnt]# crontab -l
30 0 * * * nice -n 19 /mnt/htpc.ksh
[root@mbpc-pc mnt]#

This will backup the other drives that I'm sharing to the RAID6 storage we've created.  Next we will take the key bits from there to create separate cron jobs in case scripting or KSH is not your thing.  This is just as good and may be quicker as it'll be ran in parallel (again type crontab -e to get in and edit the crontab file):

30 0 * * * nice -n 19 rsync -avc –progress /mnt/FLASHLexarMedia-32GB-1 /mnt/HTPCBackupXFS;
30 0 * * * nice -n 19 rsync -avc –progress /mnt/FLASHLexarMedia-32GB-0 /mnt/HTPCBackupXFS;
30 0 * * * nice -n 19 rsync -avc –progress /mnt/FLASHKingstonCenton /mnt/HTPCBackupXFS;
30 0 * * * nice -n 19 rsync -avc –progress /mnt/VGEnt /mnt/HTPCBackupXFS;
30 0 * * * nice -n 19 rsync -avc –progress /mnt/HTPCFileStorage /mnt/HTPCBackupXFS;

Naturally, both methods work just as well and you may benefit from some parallelism here doing it the above way.  However, as more sources are managed, this may become more difficult to manage and more editing will be needed.  The above job schedules the backups to start 30 minutes past midnight, 0 and runs every day, *, every month, * each year, *, respectively from left to right.

Cheers,
TK

Leave a Reply

You must be logged in to post a comment.


     
  Copyright © 2003 - 2013 Tom Kacperski (microdevsys.com). All rights reserved.

Creative Commons License
This work is licensed under a Creative Commons Attribution 3.0 Unported License