in #hacking7 years ago (edited)

rsyncit is a shell script that I use to synchronize directories on my computer with directories on the many web sites I administer. It allows me to place a file in a directory I want to sync that contains all the necessary information to ssh to the remote host. I use keypairs instead of passwords. Always.

rsyncit requires rsync, which is included in the standard MacOS install, but which you need to install yourself in most Linux distros. It's always one of the first things I add, along with emacs, github, gcc, and Clozure Common Lisp.

Here's the script:

if [[ -z $* ]];then rsync -av ./ `./.sshdir`;else rsync $* `./.sshdir`;fi

The magic executable in each directory is named .sshdir. Here's the one in my steemit source directory:

echo $DO:/var/www/

DO is shell variable set in one of my login scripts. It's short for "Digital Ocean", my web hosting provider. Nowadays, I add symbolic names to ~/.ssh/config instead, but that's an old one.

There are two ways to use the rsyncit script.

The following synchronizes the whole directory, and all its sub-directories.


The following synchronizes just the listed files:

rsyncit -av file1 file2 ...

I slightly updated the script, so that it would not sync .git directories. Usually, it is better to git push than to simply clone the .git files.

if [[ -z $* ]];then rsync -av --exclude ".git" ./ `./.sshdir`;else rsync $* `./.sshdir`;fi

It would be more general to have an .rsyncignore file containing the patterns to ignore, but that will hair up the script a bit to check for the existence of that file. I'll do it should I need it. Or maybe I'll make a github directory containing the shell scripts I've written over the years.

Coin Marketplace

STEEM 0.20
TRX 0.06
JST 0.026
BTC 28379.88
ETH 1803.03
USDT 1.00
SBD 2.81