Last active
December 11, 2017 14:31
-
-
Save radist2s/0400adfd1535e8f86759c89442296962 to your computer and use it in GitHub Desktop.
Rsync ssh sync exmaple
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/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