[clue-admin] rsync snapshot backup script

Jeff Cann jccann at gmail.com
Wed Feb 7 06:29:46 MST 2007


I'm not sure if this is useful for clue backups, but it's an rsync 
script that will generate a snapshot backup.  We're using a variant at work.

       -----Original Message-----
      *From:  * Ayson, Joshua 
      *Sent:  * Wednesday, January 31, 2007 4:51 PM
      *To:    * Cann, Jeffery

      This is based on an old script with some modifications found at:
      _http://www.mikerubel.org/computers/rsync_snapshots/_

      I use this perl script at home, which is based on this same idea
      (but would be overkill for this project):
      _http://www.rsnapshot.org/_

      Very cool stuff!

      #!/bin/bash
      #
      ----------------------------------------------------------------------

      # basic idea is to create rotating backup-snapshots whenever called
      #
      ----------------------------------------------------------------------


      unset PATH      # avoid accidental use of $PATH

      # ------------- system commands used by this script
      --------------------
      RM=/bin/rm;
      MV=/bin/mv;
      RSYNC=/usr/bin/rsync;


      # ------------- file locations
      -----------------------------------------

      SNAPSHOT_RW=/qaweb/swami-bkup/snapshots;
      EXCLUDES=/qaweb/swami-bkup/backup_exclude;


      # ------------- the script itself
      --------------------------------------

      # step 1: delete the oldest snapshot, if it exists:
      if [ -d $SNAPSHOT_RW/hourly.3 ] ; then                  \
      $RM -rf $SNAPSHOT_RW/hourly.3 ;                         \
      fi ;

      # step 2: shift the middle snapshots(s) back by one, if they exist
      if [ -d $SNAPSHOT_RW/hourly.2 ] ; then                  \
      $MV $SNAPSHOT_RW/hourly.2 $SNAPSHOT_RW/hourly.3 ;       \
      fi;
      if [ -d $SNAPSHOT_RW/hourly.1 ] ; then                  \
      $MV $SNAPSHOT_RW/hourly.1 $SNAPSHOT_RW/hourly.2 ;       \
      fi;
      if [ -d $SNAPSHOT_RW/hourly.0 ] ; then                  \
      $MV $SNAPSHOT_RW/hourly.0 $SNAPSHOT_RW/hourly.1 ;       \
      fi;

      # step 3: rsync from the system into the latest snapshot

      $RSYNC                                                          \
              -va --delete --delete-excluded                          \
              --exclude-from="$EXCLUDES"                              \
              --link-dest=$SNAPSHOT_RW/hourly.1                       \
              /qaweb/swami-bkup/Swami/ $SNAPSHOT_RW/hourly.0 ;




More information about the clue-admin mailing list