Link to home
Start Free TrialLog in
Avatar of sunhux
sunhux

asked on

daily MSDOS batch script (.bat/.cmd) to do xcopy/e/c/h/D:d-m-y wrt 1st Sunday of the month

Hi,

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)

c)
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


SOLUTION
Avatar of AmazingTech
AmazingTech

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sunhux
sunhux

ASKER

On my PC's MSDOS prompt, the output is :
15-10-2008
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial