@Echo off
title RW Windows Server Installer v4.0 - Java Rebooter By yahgiggle
color 1b
echo ------------------------------------
echo -  RW Auto Server Installer v4.0   -
echo -           By Yahgiggle           -
echo -  Auto Update, Backup and reboot  -
echo ------------------------------------


Call RWServerSettings\Settings.bat


:timeout
echo Auto Reboot and backup countdown started
timeout /t %Reboot% /NOBREAK 
goto Backup
pause
:Backup
type NUL > version
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"
set "datestamp=%YYYY%%MM%%DD%" & set "timestamp=%HH%%Min%%Sec%"
set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
:: back up server
taskkill /pid rw_server.exe /t /F
%Serverdrive%:\%ServerFolder%\Server\7z.exe a -r "%BackupDrive%:\%BackupFolder%\Server_%fullstamp%.zip" "%Serverdrive%:\%ServerFolder%\Server"
echo Search For And Delete Any Old Backup Files
forfiles -p "%BackupDrive%:\%BackupFolder%" -m *.* -d -%BackupStored% -c "cmd  /c del /q @path"
echo "-----------------------------------------------------------------------------------"
echo The Server has been backed up and rebooted 
goto timeout
pause









