From 26f2a22823fa7991c485e304e642c8f1ef712ddc Mon Sep 17 00:00:00 2001 From: ianmdlvl Date: Sat, 3 Jun 2006 00:53:02 +0000 Subject: [PATCH] wip snaprsync --- backup/snaprsync | 78 ++++++++++++++++++++++++++++++++++++++++++++++++ cprogs/summer.c | 13 +++++--- debian/changelog | 1 + 3 files changed, 88 insertions(+), 4 deletions(-) create mode 100755 backup/snaprsync diff --git a/backup/snaprsync b/backup/snaprsync new file mode 100755 index 0000000..a2bc96d --- /dev/null +++ b/backup/snaprsync @@ -0,0 +1,78 @@ +#!/bin/bash +# +# usage: snaprsync ... +# is ---= +# 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 diff --git a/cprogs/summer.c b/cprogs/summer.c index ca65fc6..b442c71 100644 --- a/cprogs/summer.c +++ b/cprogs/summer.c @@ -25,7 +25,7 @@ #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) { @@ -160,15 +160,17 @@ static int item(const char *path, const struct stat *stab, 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)) { @@ -226,6 +228,9 @@ int main(int argc, const char *const *argv) { case 'q': quiet= 1; break; + case 'C': + hidectime= 1; + break; case 'f': errfile= stdout; break; diff --git a/debian/changelog b/debian/changelog index d59c02c..3f183f8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ chiark-utils (4.0.99.0.21) unstable; urgency=low + * Working on new `snaprsync' script. * New `summer' checksumming program with no manpage. -- -- 2.30.2