2015-08-22 18:24:25 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2016-10-12 09:16:48 +02:00
|
|
|
usage () {
|
|
|
|
cat <<EOF>&2
|
2015-08-22 18:24:25 +02:00
|
|
|
Usage: ${0##*/} SOURCE DEST
|
|
|
|
|
2016-02-22 05:06:57 +01:00
|
|
|
Use rsync to mirror SOURCE to DEST while showing progress.
|
2015-08-22 18:24:25 +02:00
|
|
|
SOURCE does not need to be ending with a trailing slash. Only size is used for
|
2018-07-27 10:34:14 +02:00
|
|
|
comparison. File perms and dates are mirrored by default.
|
2015-08-22 18:24:25 +02:00
|
|
|
|
2015-11-12 20:57:10 +01:00
|
|
|
A dry-run is made by default.
|
|
|
|
|
2015-08-22 18:24:25 +02:00
|
|
|
Options:
|
|
|
|
|
2020-03-10 11:26:06 +01:00
|
|
|
-i: Ignore CVS fils (.git and .gitignore'd files).
|
2015-11-12 20:57:10 +01:00
|
|
|
-p: Process.
|
2018-07-27 10:34:14 +02:00
|
|
|
-s: Ignore dates when comparing files.
|
2015-08-22 18:24:25 +02:00
|
|
|
|
|
|
|
EOF
|
2016-10-12 09:16:48 +02:00
|
|
|
}
|
2015-08-22 18:24:25 +02:00
|
|
|
|
2018-07-27 10:34:14 +02:00
|
|
|
## 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"
|
2016-10-12 09:16:48 +02:00
|
|
|
opt_dry="-n"
|
2020-03-10 11:26:06 +01:00
|
|
|
opt_cvs_ignore=""
|
|
|
|
while getopts ":ihps" opt; do
|
2018-07-27 10:34:14 +02:00
|
|
|
case $opt in
|
2020-03-10 11:26:06 +01:00
|
|
|
i)
|
|
|
|
opt_cvs_ignore="--cvs-exclude" ;;
|
2018-07-27 10:34:14 +02:00
|
|
|
h)
|
|
|
|
usage
|
|
|
|
exit ;;
|
|
|
|
p)
|
|
|
|
opt_dry="" ;;
|
|
|
|
s)
|
|
|
|
flags="-lr"
|
|
|
|
OPT_PROCESS=true ;;
|
|
|
|
\?)
|
|
|
|
usage
|
|
|
|
exit 1 ;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
shift $(($OPTIND - 1))
|
2015-08-22 18:24:25 +02:00
|
|
|
|
2016-10-12 09:16:48 +02:00
|
|
|
[ $# -ne 2 ] && usage && exit 1
|
|
|
|
[ "$1" = "-h" ] && usage && exit
|
|
|
|
[ "$1" = "--" ] && shift
|
|
|
|
|
2020-03-10 11:26:06 +01:00
|
|
|
rsync $opt_dry -iv $flags --size-only --delete --exclude="/lost+found" --exclude="/.Trash*" $opt_cvs_ignore --progress -- "$1"/ "$2"
|