[Tutor] Rsync script hangs after a while
Peter Otten
__peter__ at web.de
Tue Feb 4 11:59:54 CET 2014
Dayo wrote:
> I wrote this script (http://bpaste.net/show/175284/) to help me
> automate some rsync backups, and whenever I run the script for large
> syncs, it just freezes after a while, and then I have to Ctrl+C it. I
Maybe you are just lacking patience ;)
> can find any clues in both source and target /var/log/* files. Any idea
> how I can find out what's wrong with this thing?
> def tuxsync():
> """ Rsync data to target backup dir."""
> # Get config file
> config = ConfigParser.ConfigParser()
> config.read(os.getenv('HOME') + '/.tuxsync.conf')
> backupdirparent = config.get("backupsdir","backupsdir")
> remoteusername = "root"
>
> # Get the client hostname and path to the source directory which are
to be
> # synced to the backup server
> for client in [sec for sec in config.sections() if
sec.startswith('clients.')]:
> delim = '.'
> # section header is in the format [clients.<hostname>].
> # So split away the 'clients.' part, because we need just the
hostname
> clienthostname = client.split(delim)[1]
> clientpath = config.get(client, "path")
> print "clienthostname: %s\n" %(clienthostname)
> print "path: %s\n" %(clientpath)
You are throwing away all but the last clienthostname/clientpath. Is that
intentional?
> # First check for old backups and delete those
> deleteoldbackups(backupdirparent)
>
> # Create new backup
> subprocess.call(["/usr/bin/rsync", "-aEPhu", "--log-file=" +
os.getenv('HOME') + "/tuxsync.log", remoteusername + '@' + clienthostname +
':' + clientpath, backupdirparent + '/' + clienthostname +
strftime("%Y%m%d_%H%M%S") + '/'])
>
First, I'd make sure that python is involved. If it hangs on the rsync
invocation you could replace
subprocess.call(...)
with
print subprocess.list2cmd(...)
and then run the resulting line from the shell, without python. If that
freezes, too, you have to look elsewhere.
More information about the Tutor
mailing list