#!/usr/bin/env python # nbsync -- rsync based script that recursively syncs a # source directory to a remote server, written # with nano-blogger in mind (bash blog engine) # Copyleft (C) 2008 Adrian C. # All rights reversed import os import sys server = 'webserver.tld' slogin = 'username' source = '/home/username/blog/website/' remote = '/home/username/public_html/blog/' rsyncmd = ( '/usr/bin/rsync', '--verbose', # increase verbosity '--progress', # show transfer progress '--stats', # prints extra statistics '--compress', # compress files '--rsh=/usr/bin/ssh', # use ssh as the remote shell '--recursive', # copy directories recursively '--times', # keep modification times '--perms', # keep file permissions '--links', # recreate symlinks '--delete', # delete extraneous files ) if __name__ == '__main__': if len(sys.argv) > 1: raise SystemExit('Usage: %s' % os.path.split(sys.argv[0])[1]) try: os.system('%s %s %s@%s:%s' % (' '.join(rsyncmd), source, slogin, server, remote)) except Exception, error: print error