Robocopy, how to create dated directories every run?

Discussion in 'SSDs & Data Storage' started by Korialstrasza, Mar 4, 2008.

  1. Korialstrasza

    Korialstrasza Gawd

    Messages:
    561
    Joined:
    Jan 21, 2004
    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
     
  2. unhappy_mage

    unhappy_mage [H]ard|DCer of the Month - October 2005

    Messages:
    11,455
    Joined:
    Jun 29, 2004
  3. Korialstrasza

    Korialstrasza Gawd

    Messages:
    561
    Joined:
    Jan 21, 2004
    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!
     
  4. newdamage1

    newdamage1 Limp Gawd

    Messages:
    144
    Joined:
    Mar 5, 2007
    I dug around on the net yesterday for this exact thing, this is WAY simpler than the others I found, thanks!
     
  5. MrGuvernment

    MrGuvernment [H]ard as it Gets

    Messages:
    19,159
    Joined:
    Aug 3, 2004
    So how would you then write your robocopy command to automatically use the newly created dated directory?
     
  6. drescherjm

    drescherjm [H]ardForum Junkie

    Messages:
    14,296
    Joined:
    Nov 19, 2008
    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..
     
  7. _Gea

    _Gea 2[H]4U

    Messages:
    3,805
    Joined:
    Dec 5, 2010
    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
     
  8. MrGuvernment

    MrGuvernment [H]ard as it Gets

    Messages:
    19,159
    Joined:
    Aug 3, 2004
    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.
     
  9. David-Duc

    David-Duc [H]ard|Gawd

    Messages:
    1,050
    Joined:
    Dec 22, 2010
    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: Oct 5, 2016