Skip to content

Instantly share code, notes, and snippets.

@chatlamin
Last active September 8, 2017 08:22
Show Gist options
  • Select an option

  • Save chatlamin/1918ccda5e32c267c0c1572d78cd5cc2 to your computer and use it in GitHub Desktop.

Select an option

Save chatlamin/1918ccda5e32c267c0c1572d78cd5cc2 to your computer and use it in GitHub Desktop.
Резервное копирование NTbackup
@echo off
::-------------------------------------------------------------------
:: Settings
::-------------------------------------------------------------------
SET BACKUPPATH=\\192.168.1.131\share\backups\srv2008lab\WindowsImageBackup
SET SERVERNAME=srv2008lab
SET ROTATEDAY=5
:: Plug-in storage
net use s: %BACKUPPATH%
SET DISKPATH=S:\
:: Migration backup
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set dt=%%a
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 stamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%
move %DISKPATH%%SERVERNAME% %DISKPATH%%SERVERNAME%"%stamp%"
:: Rotate backup
forfiles /p %DISKPATH% /d -%ROTATEDAY% /c "cmd /c rd /q /s @path"
net use s: /d /y
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment