File: backup_zone

package info (click to toggle)
spamassassin 4.0.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 25,724 kB
  • sloc: perl: 89,143; ansic: 5,193; sh: 3,737; javascript: 339; sql: 295; makefile: 209; python: 49
file content (76 lines) | stat: -rwxr-xr-x 1,778 bytes parent folder | download | duplicates (4)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
#
# a basic backup script for the stuff on the zone; we can't check it all
# in due to (a) volume and (b) embedded rsync passwords in .corpus files etc.
#
# run as root, a la
#
#    sudo /export/home/svn-trunk/backend/root/backup/backup_zone

bupdir=/zonestorage/spamassassin/backup
[ `uname -n` = spamassassin2 ] && bupdir=/zonestorage/spamassassin2/backup

###########################################################################

die () {
  echo "$*" 1>&2
  exit 1
}

rsyncup () {
  dir="$1"
  name=$2

  rsync=rsync
  [ -x /usr/sfw/bin/rsync ] && rsync=/usr/sfw/bin/rsync
  [ -x /opt/sfw/bin/rsync ] && rsync=/opt/sfw/bin/rsync
  [ -x /opt/csw/bin/rsync ] && rsync=/opt/csw/bin/rsync

  excludedir=`dirname $0`

  [ -d rsynced/$name ] || mkdir -p rsynced/$name
  chmod 700 rsynced

  touch $name.log
  chmod 600 $name.log

  (
    #nice -20 $dtar --create --file=-  \
        #--sparse --exclude-from=$excludedir/excludes  \
        #--label="Backup of $dir at `date`"  \
        #"$dir" | nice -20 gzip -2

    nice -20 $rsync -a \
        --hard-links --whole-file --delete \
        --sparse --exclude-from=$excludedir/excludes \
        "$dir/." "rsynced/$name/."

  ) > $name.log 2>&1
}

###########################################################################

mkdir -p $bupdir 2>/dev/null
cd $bupdir || die "failed to cd to $bupdir"

[ -f LOG   ] && mv LOG   LOG.1
[ -f LOG.1 ] && mv LOG.1 LOG.2

(
for dir in `ls /export/home` ; do

  [ "$dir" = "OBSOLETE" ] && continue
  rsyncup /export/home/$dir        export-home-$dir

done

rsyncup /usr/local                 usr-local
rsyncup /var/www		   var-www
rsyncup /opt                       opt
rsyncup /local                     local
rsyncup /etc                       etc

) 2>&1 | tee LOG

exit 0