Skip to content

Instantly share code, notes, and snippets.

@jk0
Created September 13, 2013 17:12
Show Gist options
  • Select an option

  • Save jk0/6553389 to your computer and use it in GitHub Desktop.

Select an option

Save jk0/6553389 to your computer and use it in GitHub Desktop.
Rsync Backup Script
#!/bin/bash
DRY_RUN=false
REMOTE_HOST="<HOST>"
REMOTE_PATH="<ABSOLUTE PATH>"
LOCAL_PATH="<ABSOLUTE PATH>"
RSYNC_OPTIONS=(
-a # archive mode
-g # preserve group
-l # copy symlinks as symlinks
-m # prune empty directory chains from file-list
-o # preserve owner
-p # preserve permissions
-r # recurse into directories
-t # preserve modification times
-v # increase verbosity
-z # compress file data during the transfer
--safe-links # ignore symlinks that point outside the tree
)
if $DRY_RUN ; then
RSYNC_OPTIONS+=" -n"
fi
rsync ${RSYNC_OPTIONS[@]} -e ssh ${REMOTE_HOST}:${REMOTE_PATH} ${LOCAL_PATH}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment