Created
March 23, 2021 15:03
-
-
Save SunRed/5e4b8c14c80881912a234cda54411f9b to your computer and use it in GitHub Desktop.
Simple script utilizing rsync to sync two directories.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
read -e -p "Source Directory [./]: " SOURCE | |
SOURCE=${SOURCE:-./} | |
read -e -p "Destination Directory [../Mirror]: " DEST | |
DEST=${DEST:-../Mirror} | |
if [ $# -eq 0 ] || [ -z $1 ] | |
then | |
rsync -ai --delete --exclude={"/.*","/mirror.sh"} "${SOURCE}" "${DEST}" | |
elif [ $# -eq 1 ] && [ "$1" = "--dry-run" ] | |
then | |
echo "*** DRY RUN ***" | |
rsync -ain --delete --exclude={"/.*","/mirror.sh"} "${SOURCE}" "${DEST}" | |
else | |
echo "Unknown argument(s): ${@}" | |
exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment