Skip to content

Rsync : How to copy files from source to destination in loop sequentially ?(linux)

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?



I have got the solution, please find python the code[‘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')