Robocopy overcleans - help!
Posted on 2013-11-20
Here's what I'm trying to do. Move SQL BAK files older than 2 days from a Bakup folder to a Restore folder and then move folders older than 7 days to Kill Me and then delete the files permanently. This will run overnight to ensure that the Backup folder has all the files younger than 2 days (includes BAK, DFF, TRN, etc.), the BAK files between 2-7 days old are stored somewhere (Restore) and all BAK files over 7 days old are dekleted.
Here's the batch code I created.
robocopy U:\Backup U:\Restore /MIR /MOV /MINAGE:2 /LOG+:"u:\Backup\BackDatUp.txt" /z /np
robocopy U:\Restore U:\KillMe /MIR /MOV /MINAGE:7 /LOG+:"u:\Backup\BackDatUp.txt" /z /np
del U:\KillMe /q /LOG+:"u:\Restore\BackDatUp.txt" /z /np
Problem of course is that the BAK files in Restore are overwritten and I don't even get to the Kill Me portion becuase no file is over 7 days.
How do I move the BAK files from Backup to Restore without overwriting Restore. The folder has a separate folder for every DB.