kapott icon

backup.cmd

kapott | PRO | 01/24/19 07:33:30 AM UTC | 0 ⭐ | 5096 👁️ | Never ⏰ | []
Winbatch |

1.09 KB

|

None

|

0 👍

/

0 👎

@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

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎