I have been using rsync and it is working fine… But we keep deleting files in the destination folder and rsync keeps syncing files from the source folder. What’s the solution for this? I need to delete files from the destination and rsync should not keep syncs files again from source.
How to solve this problem for handle this programmatically using python?
Advertisement
Answer
I have got the solution, please find python the code
subprocess.call([‘rsync’, ‘-vax’, ‘–exclude-from=./list.txt’,’/home/centos/python/source/’, ‘techguy@x.x.x.x:/home/techguy/dest/’])
textfile = open(“/home/centos/python/list.txt”, “a”)
files = [f for f in os.listdir(‘./source/’) if os.path.isfile(‘./source/’ + f)]
for file in files:
textfile.write(file + 'n')
textfile.close()