@echo off

:Update 04-11-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)>>C:\MRCDBMONTHLYBACKUP.txt
echo.>>C:\MRCDBMONTHLYBACKUP.txt
echo.>>C:\MRCDBMONTHLYBACKUP.txt
echo Backup is of 'C:\Database' on %COMPUTERNAME% >>C:\MRCDBMONTHLYBACKUP.txt
echo.>>C:\MRCDBMONTHLYBACKUP.txt
echo.>>C:\MRCDBMONTHLYBACKUP.txt
echo The backup is located here: \\SU3200\MrCDatabaseBackups$\MonthEndBackups\MrCDB_%DayOfWeek%-%Month%-%Year%.zip >>C:\MRCDBMONTHLYBACKUP.txt
echo.>>C:\MRCDBMONTHLYBACKUP.txt
echo.>>C:\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 >>C:\MRCDBMONTHLYBACKUP.txt
echo.>>C:\MRCDBMONTHLYBACKUP.txt
echo.>>C:\MRCDBMONTHLYBACKUP.txt
echo Note: This is a scheduled monthly backup>>C:\MRCDBMONTHLYBACKUP.txt
echo.>>C:\MRCDBMONTHLYBACKUP.txt
echo.>>C:\MRCDBMONTHLYBACKUP.txt
echo Regards,>>C:\MRCDBMONTHLYBACKUP.txt
echo Mr Carpet Backups>>C:\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.>>C:\MRCDBMONTHLYBACKUP.txt
echo.>>C:\MRCDBMONTHLYBACKUP.txt
echo Full list of available monthly backups are as follows (check latest expected is available):>>C:\MRCDBMONTHLYBACKUP.txt
echo.>>C:\MRCDBMONTHLYBACKUP.txt
t:
cd MonthEndBackups
dir /b *.zip>>C:\MRCDBMONTHLYBACKUP.txt
echo.>>C:\MRCDBMONTHLYBACKUP.txt
echo.>>C:\MRCDBMONTHLYBACKUP.txt


net use t: /delete /y

del /Q C:\MrCDb_%DayOfWeek%-%Month%-%Year%.zip


C:
cd mrc
blat C:\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 C:\MRCDBMONTHLYBACKUP.txt

exit
