--- /dev/null
+#!/bin/bash
+#
+# usage: snaprsync <setting>... <positionals>
+# <setting> is ---<name>=<value>
+# <positionals> are assigned to unused mandatory values in order
+# mandatory:
+# rhost device mountpoint localarea
+# optional:
+ localprevious=
+ snapkind=lvm
+ rsharedir=/usr/share/chiark-backup
+ retcdir=/etc/chiark-backup
+ rvardir=/var/lib/chiark-backup
+
+badusage () { echo >&2 "snaprsync: bad usage: $1"; exit 12; }
+x () { echo "+ $@"; "$@"; }
+
+while true; do
+ case "$1" in
+ --?*=?*)
+ name=${1#--}; name=${name%%=*}
+ value=${1#--*=}
+ case "$name" in
+ rhost|device|mountpoint|localarea);;
+ localprevious|rsharedir|retcdir|rvardir);;
+ *) badusage "unknown setting $name";;
+ esac
+ eval "$name=\$value"
+ ;;
+ --) shift; break ;;
+ -*) badusage "unknown option $1" ;;
+ *) break ;;
+ esac
+ shift
+done
+
+for name in rhost device mountpoint localarea; do
+ eval "value=\$$name"
+ if [ "x$value" != x ]; then continue; fi
+ if [ $# = 0 ]; then badusage "no value for setting $name"; fi
+ eval "$name=$1"
+ shift
+done
+
+datefmt='%Y-%m-%d %H:%M:%S Z'
+
+ssh $rhost "date -u '+$rhost $datefmt'"
+ssh $rhost id
+ssh $rhost ls -d $rsharedir
+ssh $rhost ls -d $rvardir
+
+test -d $localarea || x mkdir $localarea
+ournode=`uname -n`
+rsumsfile=for-$ournode.sums
+
+x ssh $rhost "$rsharedir/snap-drop"
+x ssh $rhost "$retcdir/snap/$snapkind snap $rvardir $device $mountpoint"
+ssh $rhost "
+ set -ex
+ cd $rvardir
+ umask 077
+ exec 3>$rsumsfile
+ cd snap-mount
+ summer -Cqf . >&3
+ date -u +'sums done $datefmt'
+ cd ..
+" &
+fixme kill this thing if we die
+rsumpid=$!
+RSYNC_RSH='ssh -o compression=no' \
+ x rsync -aHSxz --numeric-ids --delete \
+ ${localprevious:+--link-dest} $localprevious \
+ $rhost:$rvardir/snap-mount/. $localarea/.
+wait $rsumpid
+x ssh $rhost "$rsharedir/snap-drop"
+RSYNC_RSH=ssh rsync -p
+ fixme use localprevious,rsums as seed if available
+ $rhost:$rvardir/$rsumsfile $localarea,rsums
#define MAXDEPTH 1024
#define CSUMXL 32
-static int quiet=0;
+static int quiet=0, hidectime=0;
static FILE *errfile;
static void fn_escaped(FILE *f, const char *fn) {
else linktarg[r]= 0;
}
- printf(" %10lu %4d %4o %10ld %10ld %10lu %10lu %10lu ",
+ printf(" %10lu %4d %4o %10ld %10ld %10lu %10lu ",
(unsigned long)stab->st_size,
(int)stab->st_nlink,
(unsigned)stab->st_mode & 07777U,
(unsigned long)stab->st_uid,
(unsigned long)stab->st_gid,
(unsigned long)stab->st_atime,
- (unsigned long)stab->st_mtime,
- (unsigned long)stab->st_ctime);
+ (unsigned long)stab->st_mtime);
+ if (!hidectime)
+ printf("%10lu ",
+ (unsigned long)stab->st_ctime);
fn_escaped(stdout, path);
if (S_ISLNK(stab->st_mode)) {
case 'q':
quiet= 1;
break;
+ case 'C':
+ hidectime= 1;
+ break;
case 'f':
errfile= stdout;
break;