Automate rsync w/ authentication
Piet van Oostrum
piet at cs.uu.nl
Fri Jul 10 17:46:23 EDT 2009
>>>>> Bryan <bryanvick at gmail.com> (B) wrote:
>B> I tried removing the internal quotes, and splitting '-e' from the
>B> other arguments. I still get the same ssh -h output however:
>B> rshArg = '/usr/bin/ssh -i /home/bry/keys/brybackup.key'
>B> args = [rsyncExec, '-a', '-v', '--dry-run', '-e', rshArg, source,
>B> dest]
>B> p = Popen(args, stdout=PIPE, stderr=PIPE)
For me it works. Of course I substituted local server names, file names
etc. I run this on Mac OS X 10.4.11. The server is some Linux system.
------------------------------------------------------------------------
#! /usr/bin/env python
from subprocess import Popen, PIPE
rsyncExec = '/usr/local/bin/rsync'
source = 'xxx.cs.uu.nl:/users/piet/yyyyyy'
dest = '/Users/piet/TEMP/test.rsync'
rshArg = '/usr/bin/ssh -i /Users/piet/.ssh/id_rsa'
args = [rsyncExec, '-a', '-v', '-e', rshArg, source, dest]
try:
p = Popen(args, stdout=PIPE, stderr=PIPE)
print 'rsync running with pid %s' % p.pid
out, err = p.communicate()
print 'Errors: %s' % err
print 'Output: %s' % out
except Exception:
print 'Error running rsync'
------------------------------------------------------------------------
It just copies the file.
--
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org
More information about the Python-list
mailing list