ambevar-dotfiles/.scripts/rmirror

32 lines
676 B
Bash
Executable File

#!/bin/sh
opt_dry="-n"
if [ "$1" = "-p" ]; then
opt_dry=""
shift
fi
if [ "$1" = "-h" ] || [ $# -ne 2 ]; then
cat<<EOF
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
exit
fi
## 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"