Intelligent FTP upload with LFTP

Ever since I started my blog, I was looking for a neat solution to upload my internet pages whenever Nanoblogger updates the local copy.

I didn’t want just a recursive upload, because some directories (e.g. data) shouldn’t be publicly accessible. My first attempt was a script using ncftpput, but it always uploads the whole site.

I wanted a more intelligent solution that copies only new and changed files. This is presumably a very common tasks, there should be plenty of ways to achieve it. But almost all FTP clients capable of intelligent uploads involve some GUI. The only command line client I could find is lftp (available on OS X from Fink and from Darwinports).

So here is my script:

# publish a nanoblogger blog

# publishing variables

PUBLISH_PATTERN="-X * -I archives/ -I images/ -I styles/ -I articles/ -I smilies/"
PUBLISH_PATTERN="$PUBLISH_PATTERN -I *.html -I *.xml -I *.rdf -I *.css -I robots.txt"
PUBLISH_PATTERN="$PUBLISH_PATTERN -I *.png -I *.jpg -I *.gif -I *.ico"


Of course you have to adjust the first three variables. The PUBLISH_PATTERN variable should be okay for the current version of Nanoblogger.

This entry was posted in OS X/Windows/Linux, The Web. Bookmark the permalink.

2 Responses to Intelligent FTP upload with LFTP

  1. Trevor Fancher says:


    I just want to say that I like your script. I am starting to use nanoblogger and this sure will come in handy! Be sure if you ever update it you update it on your site as well!


  2. Pesche says:

    My script does upload only the files that are specifically included.
    Johan Gustafsson has a slightly changed version of this script that works the other way round: upload all except what is explicitly excluded.

    By the way, I don’t use my script anymore since I switched my blog from Nanoblogger to WordPress.