I am developing a backup python program, one of the modules makes a rsync backup of a remote folder into my local device.
This is the part of the code where I have the problem:
try:
process = subprocess.Popen(
['sshpass',
'-p',
password,
'rsync',
'-avz',
'-e',
'ssh -o StrictHostKeyChecking=no',
'-p',
port,
'{}@{}:{}'.format(user, host, folder),
dest_folder],
stdout=subprocess.PIPE
)
output = process.communicate()[0]
if int(process.returncode) != 0:
print('Command failed. Return code : {}'.format(process.returncode))
exit(1)
return output
except Exception as e:
print(e)
exit(1)
The shown error is:
Unexpected remote arg: debian@12.345.67.89:/folder1/folder2/
rsync error: syntax or usage error (code 1) at main.c(1372) [sender=3.1.3]
Command failed. Return code : 1
I believe that the problem is with the array in Popen. If I run the single command in bash I rsync successfully.
What should I change from subprocess.Popen array?