Created
July 5, 2015 16:23
-
-
Save lambdalisue/72e65179f89a2766658e to your computer and use it in GitHub Desktop.
Cron script for rsync to ReadyNas
This file contains hidden or 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 | |
NAME="$1" | |
HOME=$HOME | |
HOST=0.0.0.0 | |
RSYNC=/usr/bin/rsync | |
if [[ -z $NAME ]]; then | |
echo "A name argument is required to be specified." | |
exit 1 | |
fi | |
exec {lock_fd}< $0 | |
if ! flock --nonblock ${lock_fd}; then | |
echo "A process is running. Skip the execution." | |
exit 0 | |
fi | |
# -a -rlptgoD | |
# -r recursive | |
# -l preserve links | |
# -p preserve permissions (SHOULD NOT BE USED) | |
# -t preserve modification times | |
# -g preserve group (SHOULD NOT BE USED) | |
# -o preserve owner (SHOULD NOT BE USED) | |
# -D preserve devices (SHOULD NOT BE USED) | |
# -u sync based on file update time | |
# --partial enable partial update | |
# -z compress file data | |
# --exclude=PATTERN | |
# --omit-dir-times do not preserve directory timestamp | |
# -v verbose | |
$RSYNC -rltuz -v \ | |
--partial --append \ | |
--omit-dir-times \ | |
--exclude=.* \ | |
${HOME}/$NAME/ rsync://$HOST/$NAME/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment