@echo off

if not exist c:\advantage mkdir c:\advantage
if not exist c:\advantage\backup mkdir c:\advantage\backup
if not exist c:\advantage\sysbackup mkdir c:\advantage\sysbackup
if not exist c:\advantage\logs mkdir c:\advantage\logs
if exist zip.exe move zip.exe %systemroot%\system32
if exist unzip.exe move unzip.exe %systemroot%\system32
if exist delold.bat move delold.bat %systemroot%\system32

echo Restore last backup	on %date% at %time% >> c:\advantage\Logs\advbackuplog.txt

Set yyyy=%date:~0,4%
Set mm=%date:~5,2%
Set dd=%date:~8,2%
Set HH=%time:~0,2%
Set min=%time:~3,2%
if /I %HH% LSS 10 set HH=0%HH:~1,1%


echo                !!!     This is VERY important PLEASE READ      !!!
echo. 
echo.
echo   If you are sure you know what you are doing PRESS ANY KEY to coninue
echo             OTHERWISE Press ctrl+c to terminate this batch job.
echo.
echo.
echo.
echo.
echo.
echo.
echo.
pause
echo I was sure what I was doing when pressing any key to continue with restore >> c:\advantage\Logs\advbackuplog.txt
net stop mssqlserver
c:
cd "\program files\microsoft sql server\mssql\data"
zip %yyyy%%mm%%dd%%HH%%min% adv2017.*
set advbcktime=%yyyy%%mm%%dd%%HH%%min%
move %advbcktime%.zip c:\advantage\sysbackup
unzip -o c:\advantage\backup\*.zip
net start mssqlserver
cls
echo Completed...
pause
exit
