Mired in code
Check-in [d98a5c8151]
Not logged in
Public Repositories
mwm's Repositories

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Initial version of the zfs backup script.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:d98a5c8151d628a462289e69ae908c89fde4acb3
User & Date: mwm@mired.org 2010-02-13 23:15:53
Context
2010-02-14
08:06
Minor tweaks to deal with last minute changes. check-in: 67fe0b4864 user: mwm@mired.org tags: trunk
2010-02-13
23:15
Initial version of the zfs backup script. check-in: d98a5c8151 user: mwm@mired.org tags: trunk
23:13
Initial version of the bitchin framework from the blog. check-in: 9671e5df1b user: mwm@mired.org tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added zfs/rsync-backup.sh.









































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
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
46
47
48
49
50
51
52
#!/bin/sh

BACKUP_DEST=/export/backups
BACKUP_FS=external/export/backups
BACKUP_HOST=backups
BACKUP_USER=operator

if [ "$DEBUG" = "" ]
then
    ECHO=""
else
    ECHO=echo
fi

case $(uname) in
    Darwin)
	dump_list=$(df -T ufs,hfs | awk 'NR != 1 { print $NF }') ;
	extra_flags="--extended-attribues"
	hostname=$(hostname -s) ;;
    FreeBSD)
	dump_list=$(mount -p -t ufs,zfs | awk ' { print $2 }') ;
	extra_flags="--acls --xattrs"
	hostname=$(hostname -s) ;;
    SunOS)
	dump_list=$(/usr/gnu/bin/df -P -t zfs -t ufs | awk 'NR != 1 && !/^external/ { print $NF }') ;
	extra_flags=""
	hostname=$(hostname) ;;
esac

if [ $# -eq 0 ]
then
    dump_name=$hostname
else
    dump_name=$1; shift
    dump_list="$@"
fi

for dir in $dump_list
do
    case $dir in
	/tmp*) echo Skipping $dir ;;
	*) $ECHO rsync --verbose --archive  --hard-links --delete --one-file-system --no-whole-file --exclude /.zfs $dir $BACKUP_DEST/$dump_name$dir ;;
    esac
done

SNAPSHOT_COMMAND="/usr/sbin/zfs snapshot -r $BACKUP_FS/$dump_name@$(date +%F)"
if [ "$BACKUP_HOST" = "$hostname" ]
then
    $ECHO $SNAPSHOT_COMMAND
else
    $ECHO su $BACKUP_USER -c "ssh $BACKUP_HOST 'pfexec $SNAPSHOT_COMMAND'"
fi