/ Published in: Bash
Expand |
Embed | Plain Text
# Docback 0.2 # ----------------- # A front-end to rsync: # # Back up documents to the # Simmons server space # ----------------- # Aaron Rubinstein # 7/17/08 usage() { cat <<EOF Docback Back up documents to your Simmons server space A front-end for rsync Usage: -u value [-r value] [-d] [-t] filename1 [filename2...] -u Simmons username (required) -r remote directory -d copy entire directory -t copy file only if edited in last 24 hrs -g update local file from Simmons server (use with -r) EOF exit 2; } if [ $# -lt 1 ] ; then usage; fi # Define options rflag= uflag= dflag= tflag= gflag= while getopts 'r:u:dgt' OPTION do case $OPTION in r) rflag=1 rval="$OPTARG" ;; u) uflag=1 uval="$OPTARG" ;; d) dflag=1 ;; t) tflag=1 ;; g) gflag=1 ;; ?) printf "Usage: %s: -u value [-r value] [-t] [-d] [-g] filename1 [filename2...]\n" $(basename $0) >&2 exit 2 ;; esac done shift $(($OPTIND - 1)) # If "-d" specified, recursively copy directory with rsync if [ "$dflag" ] ; then rsync -vtr $* $uval@cleo.simmons.edu:/users/gslis/$uval/$rval fi # If "-t" specified find file if edited within last 24 hrs if [ "$tflag" ] ; then FILE=$(find ${HOME}/ -mtime -1 -name $*) # If nothing found, print message and exit if [ ! $FILE ] ; then echo "File has not been edited within last 24 hours" exit 1; fi fi if [ "$gflag" ] ; then # Update local folder with contents of remote folder rsync -vtr $uval@cleo.simmons.edu:/users/gslis/$uval/$rval $* fi # Send found file(s) via rsync rsync -v -t --progress $* $uval@cleo.simmons.edu:/users/gslis/$uval/$rval
You need to login to post a comment.
