Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ECHO off
- SETLOCAL ENABLEEXTENSIONS
- SET me=%~n0
- SET parent=%~dp0
- :configurables
- SET _srvname_=yourservernamehere
- SET _compressioncmd_=7z a -r -tzip -bb0 -mx5
- :set_backup_filename_tags
- SET _date_=%date:~3,10%
- :: getting 24h timestamp in windows...
- SET hour=%time:~0,2%
- IF "%hour:~0,1%" == " " (SET hour=0%time:~1,1%)
- SET mins=%time:~3,2%
- SET secs=%time:~6,2%
- SET stamp=%hour%%mins%%secs%
- SET tag=%_srvname_%_%_date_%_%stamp%
- :set_dirs
- SET srvdir=%cd%
- cd ..
- SET backupdir=%cd%\backups\%_srvname_%
- SET tempdir=%temp%\%tag%
- :copy_to_temp
- ECHO [%me%] Copying server to temp dir...
- xcopy /q /f /e /i %srvdir% %tempdir% > nul
- :compress
- ECHO [%me%] Compressing the copied server files..
- %comspec% /Q /C %_compressioncmd_% %backupdir%\%tag%.zip %tempdir%\*.* > nul
- :cleanup
- ECHO [%me%] Removing temp files..
- rmdir %tempdir% /s /q
- IF /I "%ERRORLEVEL%" NEQ "0" (goto error_compression) else (goto done)
- :error_compression
- ECHO [%me%] An error occurred whilst trying to compress!
- EXIT /B 1
- :done
- ECHO [%me%] All done! Backup file created: %backupdir%\%tag%.zip
- exit /B 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement