Robocopy, how to create dated directories every run?

Joined
Jan 21, 2004
Messages
561
Hey guys,
is it possible to have robo copy create a new folder for the copies every time it runs?

Like:
C:\backups\3-1-08\
C:\backups\3-2-08\
C:\backups\3-3-08\
C:\backups\$date
etc.

instead of just overwriting the same directory over and over?

Thanks guys
 
Excellent, worked great!

Now, what will happen when the HD I'm backing up to is full? Can I set some way to delete directories after x days or something?

Thanks.

Edit: think I found the answer, gotto make a batch file to delete the stuff that are older than x days and schedule it to run every so often. Pretty neat, there's a whole world of batch fun!
 
So how would you then write your robocopy command to automatically use the newly created dated directory?
 
Following from the example where %date% is todays date.

Code:
mkdir %date%

robocopy mysourcepath %date% myrobocopyoptions

That assumes you are currently in the folder where your destination backups go..
 
So how would you then write your robocopy command to automatically use the newly created dated directory?

I use robocopy to do daily syncs of my 25 TB fileserver. I wrote a small batchfile to do the sync and mail me
a summary of the result. I need a history of the files (daily, weekly etc)

But I do not use a folder for each day (impossible with the data size) but sync the filer to a ZFS storage
and do snapshots there. Robocopy only needs to sync the small amount of changed files. ZFS delivers
the state of each day without the need of storing unchanged files.

Daily folders for robocopy are only an option with a very small amount of data
 
Noted about using the %data%

Makes sense, good to know, right now i have it doing about 90G for one folder it is a structured folder for departments to use to store common files and each has a personal folder as well. i also have roaming profiles which is around 300G right now, but i am filtering out files like virtual machines that people set up and other files that arent critical, and that gets dumped as well to a main server i am using to store the data with 8T of storage space on raid 6 with a hot spare.

The common folders are on one server, the roaming profiles on another, so i am using robocoy to dump copies to the main data store server, to which i am then going to dump it to an offsite server from there once i can get winrar or 7zip to do an auto compression of the copied over files, i am also have MySQL dumps being stored on that server using navicat and compression.

I think with that once it hits the offline server i can do the daily versions from there compressed in zip/rar format and toss the date in the file name or something......but it is only a dual core system where as my main backup server is an Xeon E-1300 i recall with much faster drives in it.
 
I know this thread is old but I found a much more simple way to do it:
robocopy auto backup.PNG

Code:
robocopy "C:\Source" "D:\Destination\%date:/=_%\%time::=_%" /mir
This will create a new folder with date\time every time you run.

There are 2 variables: %date% and %time% and they're region dependent, for me they're "day mm/dd/yyyy" and "hh:mm:ss.ss", respectively. You will then need ":/=_" to change "/" into "_" and "::=_" to change ":" into "_" since they're invalid for names.

/MIR switch is to mirror the source directories and files
 
Last edited:
Back
Top