snaprep

git mirror of https://ccx.te2000.cz/bzr/snaprep
git clone https://ccx.te2000.cz/git/snaprep
Log | Files | Refs

snap.rsync.post (624B)


      1 #!/bin/sh
      2 exec 1>&2
      3 env | grep RSYNC | sort | tr '\n' '\t'; echo
      4 
      5 set -x
      6 
      7 case $RSYNC_MODULE_NAME in
      8 	(*.push) ;;
      9 	(*) exit 1;;
     10 esac
     11 
     12 for m in $RSYNC_MODULE_PATH/.snapshot.[0-9]*; do
     13 	test -f "$m" || continue
     14 	test -n "$mark" && exit 1
     15 	mark=$m
     16 done
     17 
     18 test -f "$mark" || exit 1
     19 
     20 snap_dir=${RSYNC_MODULE_PATH%/*}
     21 
     22 if test -f "$snap_dir/${mark##*/}"; then
     23 	# already have this snapshot
     24 	rm -f "$mark"
     25 	exit $?
     26 fi
     27 
     28 ts=${mark##*.}
     29 rsync -aA --exclude=/.snapshot.\* --link-dest="$RSYNC_MODULE_PATH/" "$RSYNC_MODULE_PATH/" "$snap_dir/$ts/" || exit $?
     30 touch "$snap_dir/$ts/${mark##*/}" || exit $?
     31 mv "$mark" "$snap_dir/" || exit $?