rsync over different ssh port

I use rsync quite often to synchronize my development & production server. Rsync is really helpful & handy tool with lot of tweaks & configuration to satisfy most of your needs. Normally I created a script to make a call to rsync

LOCK_FILE="/tmp/rsync_backup.lock"
LOG_FILE="/tmp/rsync_backup.log"
RSYNC="/usr/bin/rsync"

if [ -e $LOCK_FILE ]; then
        TIMESTAMP=$(date)
        echo "$TIMESTAMP: lock file exists, exit now" >> $LOG_FILE
        exit
fi

cat /dev/null > $LOG_FILE

touch $LOCK_FILE
$RSYNC -e "ssh" -rca --delete-after /my/local/development/path/here/ ssh_username@host_name_or_ip_address:/my/production/server/path/

In case you want to use a different SSH port, then it’s easy to change

$RSYNC -e 'ssh -p 8022' -rca --delete-after /my/local/development/path/here/  ssh_username@host_name_or_ip_address:/my/production/server/path/

Change 8022 to your actual port and you are done!

Related posts:

Share

About number.0