• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Command Script - Automated Backup

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

quadcore86

Member
Joined
Jul 9, 2007
I'm trying to write a command script that will perform an automated backup.

My drives are as follows:
D:\Data
W:\Archive\

I want to backup everything in D:\Data to W:\Archive AND I want it to backup in a "date" folder. So for today's backup, it will copy everything from D:\Data to
W:\Archive\08022007\.


Does anyone know the script command to do this?
 
Code:
REM Create folder respective to current date
SET MO=%DATE:~4,2%
SET DAY=%DATE:~7,2%
SET YR=%DATE:~-4%
MD %MO%-%DAY%-%YR%

REM XCOPY files using specified switches to current date directory
XCOPY /E /F /G /H /I /R /K /Y D:\DATA W:\ARCHIVE\%MO%-%DAY%-%YR%

This should work, although I did not test it. You can look up XCOPY and see if you want to add/remove/change any of the switches I included. It all depends on what you are doing, but that is a collection of switches that will allow most everything while not harming anything if not needed.

Change the drive letters/locations around and test it. Let me know if it's borked.
 
Back