@echo off

:Update 03-07-2013 (PG)

blat -install smtp.mrcuk.mr-carpet.co.uk mrcbackups@mr-carpet.co.uk


if exist C:\MrC\Servers\ServerTasks\BackupMrC_DB_toSU3200.txt del C:\MrC\Servers\ServerTasks\BackupMrC_DB_toSU3200.txt

: Extract the date and apply it to variables.
for /F "tokens=1-4 delims=/ " %%i in ('date /t') do (
    set DayOfWeek=%%i
    set Month=%%j
    set Year=%%k
)


echo MRC Monthly DB Backup Complete on %DayOfWeek%-%Month%-%Year% (time as of email)>>D:\MRCDBMONTHLYBACKUP.txt
echo.>>D:\MRCDBMONTHLYBACKUP.txt
echo.>>D:\MRCDBMONTHLYBACKUP.txt
echo Backup is of 'D:\Database' on %COMPUTERNAME% >>D:\MRCDBMONTHLYBACKUP.txt
echo.>>D:\MRCDBMONTHLYBACKUP.txt
echo.>>D:\MRCDBMONTHLYBACKUP.txt
echo The backup is located here: \\SU3200\MrCDatabaseBackups$\MonthEndBackups\MrCDB_%DayOfWeek%-%Month%-%Year%.zip >>D:\MRCDBMONTHLYBACKUP.txt
echo.>>D:\MRCDBMONTHLYBACKUP.txt
echo.>>D:\MRCDBMONTHLYBACKUP.txt
echo The Month End DB backup can be retrieved otely here: ftp://217.40.222.185/dbbackup/MonthEndBackups/MrC_DB_MonthEnd_%Month%-%Year%.zip >>D:\MRCDBMONTHLYBACKUP.txt
echo.>>D:\MRCDBMONTHLYBACKUP.txt
echo.>>D:\MRCDBMONTHLYBACKUP.txt
echo Note: This is a scheduled monthly backup>>D:\MRCDBMONTHLYBACKUP.txt
echo.>>D:\MRCDBMONTHLYBACKUP.txt
echo.>>D:\MRCDBMONTHLYBACKUP.txt
echo Regards,>>D:\MRCDBMONTHLYBACKUP.txt
echo Mr Carpet Backups>>D:\MRCDBMONTHLYBACKUP.txt


cls
echo Mapping a drive to the destination folder...
echo.
echo.
net use t: \\SU3200\MrCDatabaseBackups$

copy /V /Y T:\MrCDB_%DayOfWeek%-%Month%-%Year%.zip T:\MonthEndBackups\MrC_DB_MonthEnd_%Month%-%Year%.zip

echo.>>D:\MRCDBMONTHLYBACKUP.txt
echo.>>D:\MRCDBMONTHLYBACKUP.txt
echo Full list of available monthly backups are as follows (check latest expected is available):>>D:\MRCDBMONTHLYBACKUP.txt
echo.>>D:\MRCDBMONTHLYBACKUP.txt
t:
cd MonthEndBackups
dir /b *.zip>>D:\MRCDBMONTHLYBACKUP.txt
echo.>>D:\MRCDBMONTHLYBACKUP.txt
echo.>>D:\MRCDBMONTHLYBACKUP.txt


net use t: /delete /y

del /Q D:\MrCDb_%DayOfWeek%-%Month%-%Year%.zip


C:
cd mrc
blat D:\MRCDBMONTHLYBACKUP.txt -to pete@guyans.co.uk,davidguyan@mr-carpet.co.uk,davidcooper@mr-carpet.co.uk -subject "%Month%-%Year%: MRCDB Monthly Backup Completed"

del /Q D:\MRCDBMONTHLYBACKUP.txt

exit
