Skip to content

Instantly share code, notes, and snippets.

@lambdalisue
Created July 5, 2015 16:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lambdalisue/72e65179f89a2766658e to your computer and use it in GitHub Desktop.
Save lambdalisue/72e65179f89a2766658e to your computer and use it in GitHub Desktop.
Cron script for rsync to ReadyNas
#!/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