@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 Executed Restore Backup	on %date% at %time% >> c:\advantage\Logs\advbackuplog.txt

echo %date% %time% > f:\ns
if not exist f:\ns goto nodisk
del /Q f:\ns

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%


:Backup

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

if not exist f:\backup.zip goto warning

echo I was sure what I was doing when pressing any key to continue with restore >> c:\advantage\Logs\advbackuplog.txt
c:
net stop mssqlserver
cd "\program files\microsoft sql server\mssql\data"
zip -m %yyyy%%mm%%dd%%HH%%min% adv2017.*
set advbcktime=%yyyy%%mm%%dd%%HH%%min%
move %advbcktime%.zip c:\advantage\sysbackup
unzip -o f:\backup.zip
net start mssqlserver
cls
echo Completed...
pause
exit

:nodisk
cls
color 47
echo No Flash Disk in drive 	on %date% at %time% >> c:\advantage\Logs\advbackuplog.txt
echo Drive f: does not exist, you probably do not have your flash disk in.
echo Please insert your flash disk and run the backup again.
pause
color 07
exit

:warning
color 47
cls
echo !!! There is no Backup.zip on your flash disk.
echo.
echo These are the only files on your flash disk:
echo.
dir f: /B
echo.
pause
exit