Safe deletion on remote server

Advertisement

Guest
Guest

Safe deletion on remote server

Thanks for a great application!

I need to use windows scheduler to get all files in a mailbox-directory on a remote server, check if "get" was flawless, and then delete the downloaded files on the remote server. The process is repeated every 15 minutes. This can be done using .bat files and a winSCP-script.

BUT, a nasty situation can arise: E.g. 10 files are found in the remote directory. All 10 files are downloaded. While in process of downloading a new file, #11, is posted in the remote derectory (by an automatic process on the remote host - needless and complicated to explain here). If I delete all files in the remote directory, then only 10 files are moved to the local server. File #11 will be deleted without being downloaded.

Any way to avoid this using WinSCP?

regards
Michael Bruus

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: Safe deletion on remote server

Move the remote files to another remote directory and download and delete them only from there.

Reply with quote

andyn
Guest

delete just files that were transferred

This is well after the fact but thought I'd put it out here in case someone has a similar problem.
I need to do something very similar to what Michael describes but don't have rights to create directories on the remote server.

In my case, file names are well defined such as I need to pick up pickup*.txt (and I'll be dropping off files named like droppedoff*.txt which I can ignore). I do a mv to a new name format such as a new extension and in the get can switch the destination extension back so my local files are the expected extension still.

mv pickup*.txt pickup*.get
get pickup*.get pickup*.txt
rm pickup*.get

Assuming the other end is always putting pickup files with .txt extensions and never .get extensions (in other words I always control what is named .get) then only items at the time of the mv will be dealt with on the get and the rm and any new files during my connection will be .txt and ready for the next time I run the script.

This at least handle doing the get and the rm to the same set of files.

Reply with quote

Advertisement

You can post new topics in this forum