Backing up an OSX profile to a linux server with rsync

TimeMachine is some nice software, but its overkill for me. I've previously written about this and how I put together a rsync solution and why I did so. In the case that anyone might be interested in doing the same, here is my setup.

Linux Server
I have a gentoo linux server, but this should be a mostly generic rsync server setup. My rsyncd.conf looks like this

# /etc/rsyncd.conf
# This line is required by the /etc/init.d/rsyncd script
pid file = /var/run/rsyncd.pid
use chroot = yes
read only = no
uid = bed
gid = bed
hosts allow = 192.168.42.0/24

[bed-backup]
    path=/mnt/backup/bed
    comment = Beds Backup

and of course rsyncd is in my /etc/init.d and starts automatically at boot.

OSX

I have a simple bash script that I can run that will backup the contents of my home directory, called backup_bed.sh. This will turn sleep off, make sure the network is available (as the machine may have been woken from sleep) and then do the backup.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/sh
#Bed's rsync backup script

echo `date` Beds Backup > last_backup.log
echo `date` ------------- >> last_backup.log
echo `date` Script Starting at `date` >> last_backup.log

# turn off system sleep
pmset -a sleep 0 2>&1 >> last_backup.log
echo `date` Turned off sleep >> last_backup.log

echo `date` ------------- >> last_backup.log

# wait for network to show up
pingcount=0
trycount=1
failflag=0
while [ $pingcount -eq 0 ]
do
    echo `date` Waiting for network... $trycount >> last_backup.log
    pingcount=$(/sbin/ping -c 3 -o bedentoo | grep "received" | awk -F',' '{ print $2 }' | awk '{ print $1 }')
    trycount=`expr $trycount + 1`
    if [ $trycount -eq 11 ]
    then
        echo `date` network fail - giving up >> last_backup.log
        failflag=1
        pingcount=-1
    fi
done

if [ $failflag -eq 0 ]
then
        #do rsync
        echo `date` RSync started.  >> last_backup.log
        /usr/bin/rsync -a -x -S -v -v --progress --exclude-from=/Users/bed/scripts/backup_excludes.txt  /Users/bed/ bedentoo::bed-backup 2>&1 >> last_backup.log
        echo `date` RSync finished.  >> last_backup.log
fi

#turn system sleep back on
echo `date` ------------- >> last_backup.log
pmset -a sleep 30 2>&1 >> last_backup.log
echo `date` Turned on sleep for …

Read More