I’m running several robocopy scripts as scheduled tasks, and want to see where I’m going wrong.

I have a backup application that drops data onto a server (NAS1).

A robocopy script copies the data from the server onto a remote server later that evening (NAS2).

A second robocopy script runs and is supposed to move the files that are 15 days old to a ‘delete me’ folder, where the files would then get deleted.

What’s happening, though, is that the robocopy script is scanning every single file in the folders, and anything that’s 15 days old or more, is getting moved, so all the windows system files, etc. are moved out of the folder to the ‘delete me’ folder each day, while the newer files are staying in the folder. I want the script to look at the age of the top folder only, and move the entire folder if it’s older than 15 days, so that my entire system backup is intact.

Here’s my current robocopy script:

C:\Scripts\robocopy.exe "\NAS1\backup\INTRANET\Incremental" “\NAS2\backup\INTRANET\Files_for_Deletion” /e /MOVE /MINAGE:15 /LOG+:“B:\Backups\Logs\NAS_Incr_Delete.txt”

Do I simply need to remove the /e from the script?

2 Spice ups

I’m guessing that the script that copies to NAS2 create a new folder each night. That’s why you can use the creation date of the folder as the date test?

It moves the folder over from NAS1 to NAS2, so depending on how you look at it, yes, it creates a new folder each night.

I removed the /e and the E from /MOVE, and ran the script. The log basically said that there was nothing to move, which confused me, as there are two month old files in there. That’s when I compared the Modified Date and the Created Date. The modified date is two months old, but the created date is only three days old. :slight_smile: So, it appears that robocopy is looking at the created date now. That’s no big deal. I’ll wait another two weeks to see if the script functions normally as files get to be 15 days old.

You could try richcopy

You say you have one script that copies data from NAS1 to NAS2 and then another script that does the file move. The script you posted, however, appears to attempt to do both.

If the first script uses the proper switches, it should copy the file attributes correct, including timestamps, yes?

If the second script is JUST to move out the aged files, then instead of working on the entire data structure, you specify the desired folder as your root point:

If "\NAS1\backup\INTRANET\Incremental" is your entire structure, then use “\NAS1\backup\INTRANET\Incremental\desired_folder” as the target of your script that moves based on age.

1 Spice up

I like the copy from NAS1 to NAS2.

Sorry - to clarify, these are lines from two different scripts running on the same server. One moves it to the onsite NAS used for backups. The second one is the one that is supposed to delete the folder after 15 days.

I believe that the file attributes are copied, correct.

The problem with ( then use “\NAS1\backup\INTRANET\Incremental\desired_folder” ), is that the folders are time/date stamped by the backup software, so I don’t know of any way we can pre-fill that folder name.

I’ve tried C:\Scripts\robocopy.exe \NAS2\backup\INTRANET\Full\ both with and without the / at the end, but this has had no effect.

@rgibson Aug 8, 2014 at 11:39 AM

"I like the copy from NAS1 to NAS2. "

NAS1 is our LAN backup target. NAS2 is our offsite backup target.

So, I had a thought. Would it make sense to have the script change the file attributes on all the files copied in script 1 so that they have a modified or created date for the date that they’re moved? This would, in theory, prevent script 2 from moving system files, etc.

Thoughts?