local/bin/rmirror: Add option to ignore date comparison
parent
f0c6aeab00
commit
e4d50259b1
|
@ -6,28 +6,43 @@ Usage: ${0##*/} SOURCE DEST
|
|||
|
||||
Use rsync to mirror SOURCE to DEST while showing progress.
|
||||
SOURCE does not need to be ending with a trailing slash. Only size is used for
|
||||
comparison. File perms and dates are mirrored.
|
||||
comparison. File perms and dates are mirrored by default.
|
||||
|
||||
A dry-run is made by default.
|
||||
|
||||
Options:
|
||||
|
||||
-p: Process.
|
||||
-s: Ignore dates when comparing files.
|
||||
|
||||
EOF
|
||||
}
|
||||
|
||||
## We use archive mode '-a' which preserves perms and dates. On non-POSIX
|
||||
## filesystems, you might want to skip this and preserve symlinks only by
|
||||
## replacing -a with -lr.
|
||||
flags="-a"
|
||||
opt_dry="-n"
|
||||
if [ "$1" = "-p" ]; then
|
||||
opt_dry=""
|
||||
shift
|
||||
fi
|
||||
while getopts ":hps" opt; do
|
||||
case $opt in
|
||||
h)
|
||||
usage
|
||||
exit ;;
|
||||
p)
|
||||
opt_dry="" ;;
|
||||
s)
|
||||
flags="-lr"
|
||||
OPT_PROCESS=true ;;
|
||||
\?)
|
||||
usage
|
||||
exit 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
|
||||
[ $# -ne 2 ] && usage && exit 1
|
||||
[ "$1" = "-h" ] && usage && exit
|
||||
[ "$1" = "--" ] && shift
|
||||
|
||||
## We use archive mode '-a' which preserves perms and dates. On non-POSIX
|
||||
## filesystems, you might want to skip this and preserve symlinks only by
|
||||
## replacing -a with -lr.
|
||||
rsync $opt_dry -iv -a --size-only --delete --exclude="/lost+found" --progress -- "$1"/ "$2"
|
||||
rsync $opt_dry -iv $flags --size-only --delete --exclude="/lost+found" --progress -- "$1"/ "$2"
|
||||
|
|
Loading…
Reference in New Issue