Friday, November 12, 2010

Rsync and vim

Monday and Tuesday was vim. Apparently you can run a command inside vim by adding ! before it. Seems very nice for when your physically work at a server and you don't have to close out of vim. Another very awesome feature is that you can split your windows vertically or horizontally in vim to display two files or the same one. You either run split or vsplit and the file after it if you want the window to have another file. Most of the time I don't need this since I can just ssh multiple times but as before this could be a big help when interacting directly with a server. Onto rsync.

Jeff wants a backup in place for our LTSP and he pointed me towards rsync. Rsync copies files but as implied it syncs them so it only overwrites a file if it has changed so less bandwidth is wasted and time. It can also retain file permissions which is cool beans. It will also be run as cron job so it occurs every night. I've researched it and this seems to be the most comprehensive article on rysnc and cron.

What will happen is I will generate ssh keys for our servers because without them it isn't possible for the LTSP server to run the script without entering a password. Once the keys are in place and the ssh config is modified I will create a script along the lines of this.



echo $’\n\n’ >> $LOGFILE
echo “Completed at: `/bin/date`” >> $LOGFILE

I'm debating whether to just make the script one line or use this one where you modify the variables. After that I will use crontab to have the script run ever night and backup the home directory and everything will be hunky dory. Or so I hope.


  1. Great work!

    Take a look at to see an example binding a key () to an action running in the shell from vim. This little config file turns vim into the fastest Python ide I've ever used.

    I maintain a .bash_aliases file which contains lines like:

    alias tcse='rsync -avz -e ssh --delete /home/jelkner/Projects/thinkcspy2e/build/; rsync -avz -e ssh --delete /home/jelkner/Projects/thinkcspy2e/resources/'

    With this I can run: $ tcse and sync the work I'm doing on my Python book to the hosting site at

  2. Please setup a test environment with your rsync chron job running before actual deployment.