Reputation: 3801
I've got some automation backup script that executing rsync
using subprocess
module.
It was all fine until the new requirement to specify ssh identity file.
According to rsync
manuals, ssh identity should be passed as quoted string:
-e "ssh -i /home/username/.ssh/identity"
But this will fail to run in subprocess
:
subprocess.Popen(['rsync', '-avz', '-e "ssh -i /home/username/.ssh/identity"', '~/Downloads', 'root@remote_server:/lvm/archive/backup'])
<subprocess.Popen object at 0x7fd111939710>
rsync: Failed to exec ssh -i /home/username/.ssh/identity: No such file or directory (2)
rsync error: error in IPC code (code 14) at pipe.c(85) [sender=3.1.0]
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: error in IPC code (code 14) at io.c(226) [sender=3.1.0]
Any idea?
Thanks
Upvotes: 0
Views: 1763
Reputation: 95159
subprocess.Popen(['rsync', '-avz', '-e', 'ssh -i /home/username/.ssh/identity', '~/Downloads', 'root@remove_server:/lvm/archive/backup'])
Upvotes: 1