Skip to content

Instantly share code, notes, and snippets.

@radist2s
Last active December 11, 2017 14:31
Show Gist options
  • Save radist2s/0400adfd1535e8f86759c89442296962 to your computer and use it in GitHub Desktop.
Save radist2s/0400adfd1535e8f86759c89442296962 to your computer and use it in GitHub Desktop.
Rsync ssh sync exmaple
#!/bin/sh
if [ -e ~/rsyncjob.lock ]
then
echo "Rsync job already running...exiting"
exit
fi
touch ~/rsyncjob.lock
# beter speed but not available for short identifier keys
# export RSYNC_RSH="ssh -c arcfour -o Compression=no -x"
export RSYNC_RSH="ssh -o Compression=no -x"
if [ -z "$3" ] || [ $3 != true ]
then
TEST=-nvi
fi
SOURCE_DIR=$1 #~/sync-source
DEST_DIR=$2 #user@host:~/sync-dest
rsync $TEST -zaP $SOURCE_DIR $DEST_DIR
rm ~/rsyncjob.lock
# Usage
# ./rsync-ssh.sh ~/source-dir ~/dest-base-dir true
# Dry run
# ./rsync-ssh.sh ~/source-dir user@host:~/dest-base-dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment