#!/bin/sh # # Archive a user directory. # - Cameron Simpson 21feb2001 # archhost=shot archhdir=/StorNext/Archive/users archive=/usr/local/archive/users cmd=`basename "$0"` usage="Usage: $cmd users..." [ $# = 0 ] && { echo "$cmd: missing users" >&2; echo "$usage" >&2; exit 2; } xit=0 for user do [ -d "$user" ] || { echo "$cmd: $user: not a directory" >&2 xit=1 continue } wd=`pwd` || { xit=1; continue; } case "$wd" in /a/*/home) host=`expr "$wd" : '/a/\([^/]*\)/home'` ;; *) echo "Don't know how to tag files from $wd" >&2 xit=1 continue ;; esac rbase=$user-$host-`daycode` rdir=$archhdir/$rbase dbuser "$user" ypmatch "$user" passwd ls -ld "$user" ask "archive $user to $archhost:$rdir" || continue ssh "$archhost" "set -x; mkdir '$rdir'" \ || { xit=1 continue } # then make sure it's all ok set-x rsync -avHWP "$user/." "$archhost:$rdir/." echo echo checking "$rdir..." rsync -avHn "$user/." "$archhost:$rdir/." echo echo "updating $user ..." set-x dbuser -e "$user" "HOMEDIR=$archive/$rbase" echo echo "Now you must:" echo " rmr $user" echo done exit $xit