daily MSDOS batch script (.bat/.cmd) to do xcopy/e/c/h/D:d-m-y wrt 1st Sunday of the month
Posted on 2008-10-14
I need a daily .bat/.cmd MSDOS script that runs at 1am that will :
a)If it's the first Sunday of the month, do :
xcopy/E/C/H/Y n:\folder1 n:\backup\folder1\yyyymmdd > n:\log\yyyymmdd_folder1.txt 2>> n:\log\yyyymmdd
xcopy/E/C/H/Y n:\folder2 n:\backup\folder2\yyyymmdd > n:\log\yyyymmdd_folder2.txt 2>> n:\log\yyyymmdd
(ie take a full backup of folder1 & folder2; yyyymmdd is the date the script run
& n: is a shared drive/folder)
b)If it's other days, do :
xcopy/E/C/H/Y/D:d-m-y n:\folder1 n:\backup\folder1\yyyymmdd > n:\log\yyyymmdd_folder1.txt 2>> n:\log\yyyymmdd
xcopy/E/C/H/Y/D:d-m-y n:\folder2 n:\backup\folder1\yyyymmdd > n:\log\yyyymmdd_folder2.txt 2>> n:\log\yyyymmdd
(this is a differential backup to backup files that have been modified or created since the
last first Sunday of the month)
in step (a) above, if it's the first Sunday of the month, it would delete away (using "deltree ?")
the folders that are 5 months old & subsequent differential backups' folders with respect to
that full backup's date.
Purpose of the >> and 2>> is to create logs for review next morning if there's
errors with backup.
If you need to break this up into multiple scripts, it's fine with me.
Single script would be nice but not essential