Hello-
I have a script (bat file, sorry its not vbscript) that copies specific db's from a server to a Snapdrive volume. the script works great but now my manager would the script to continue doing as it is BUT also to delete anything older than 90 days on that directory.
the script is run locally on the server that contains the db's and backs them up to this snapdrive location..
Can anyone help me get started with the logic behind checking the creation dates for files on that directory and if older than 90 days, delete it?
I have a slightly scrubbed version here:
@echo off
REM ****************************************************************************
REM ********* Database backup script **************************
REM ********* updated ***************************************************
REM --- Calculate date for folder date stamp
for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set DATE=%%C%%A%%B
net use s: \\snapserver\dbdirectory /user:snapserver\dbdirectory Password
echo. >> "s:\backup.log"
REM ************ MAIN **********************************************************
date /t >> "s:\backup.log"
time /t >> "s:\backup.log"
REM backup files
net stop service >> "s:\backup.log"
cd "%programfiles%\nortel networks\dbdirectory\share\"
call csbackup.bat "c:\dbdirectory\%DATE%" >> "s:\dbdirectorybackup.log"
REM --- Echo date to log file, make directory, copy files from server
mkdir "s:\%DATE%" >> "s:\dbdirectorybackup.log"
xcopy "c:\dbdirectory\%DATE%\*.*" "s:\%DATE%" /s /e /v /R /Y >> "s:\dbdirectorybackup.log"
net start service >> "s:\dbdirectorybackup.log"
IF EXIST "s:\%DATE%\*" (rmdir /s /q "c:\dbdirectory\%DATE%" >> "s:\dbdirectory.log" ) ELSE (goto :ERRORMSG)
net use s: /del
goto :EOF
:ERRORMSG
echo Could not verify copied database files... >> "s:\dbdirectorybackup.log"
net use s: /del
goto :EOF
:EOF
thank you for any information..
I have a script (bat file, sorry its not vbscript) that copies specific db's from a server to a Snapdrive volume. the script works great but now my manager would the script to continue doing as it is BUT also to delete anything older than 90 days on that directory.
the script is run locally on the server that contains the db's and backs them up to this snapdrive location..
Can anyone help me get started with the logic behind checking the creation dates for files on that directory and if older than 90 days, delete it?
I have a slightly scrubbed version here:
@echo off
REM ****************************************************************************
REM ********* Database backup script **************************
REM ********* updated ***************************************************
REM --- Calculate date for folder date stamp
for /F "tokens=2-4 delims=/- " %%A in ('date/T') do set DATE=%%C%%A%%B
net use s: \\snapserver\dbdirectory /user:snapserver\dbdirectory Password
echo. >> "s:\backup.log"
REM ************ MAIN **********************************************************
date /t >> "s:\backup.log"
time /t >> "s:\backup.log"
REM backup files
net stop service >> "s:\backup.log"
cd "%programfiles%\nortel networks\dbdirectory\share\"
call csbackup.bat "c:\dbdirectory\%DATE%" >> "s:\dbdirectorybackup.log"
REM --- Echo date to log file, make directory, copy files from server
mkdir "s:\%DATE%" >> "s:\dbdirectorybackup.log"
xcopy "c:\dbdirectory\%DATE%\*.*" "s:\%DATE%" /s /e /v /R /Y >> "s:\dbdirectorybackup.log"
net start service >> "s:\dbdirectorybackup.log"
IF EXIST "s:\%DATE%\*" (rmdir /s /q "c:\dbdirectory\%DATE%" >> "s:\dbdirectory.log" ) ELSE (goto :ERRORMSG)
net use s: /del
goto :EOF
:ERRORMSG
echo Could not verify copied database files... >> "s:\dbdirectorybackup.log"
net use s: /del
goto :EOF
:EOF
thank you for any information..