34 lines
733 B
Bash
Executable File
34 lines
733 B
Bash
Executable File
#!/bin/sh
|
|
|
|
usage () {
|
|
cat <<EOF>&2
|
|
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.
|
|
|
|
A dry-run is made by default.
|
|
|
|
Options:
|
|
|
|
-p: Process.
|
|
|
|
EOF
|
|
}
|
|
|
|
opt_dry="-n"
|
|
if [ "$1" = "-p" ]; then
|
|
opt_dry=""
|
|
shift
|
|
fi
|
|
|
|
[ $# -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"
|