Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- :: -------------------------------------------------------------
- :: CopyServerBackup.dat
- :: Version 1.0 -- June 22, 2018
- :: Parker Hannifin Corp - Micro Thermo Technologies
- :: Author: Eric Rist
- :: -------------------------------------------------------------
- :: Maintains the most recent backup in D:\AllianceBackup\ServerBackup\
- :: in preparation to be copied to the central server.
- :: -------------------------------------------------------------
- @echo off
- cls
- :: Set Destination directory
- set BACKUP_DST=D:\AllianceBackup\ServerBackup\
- if exist "%BACKUP_DST%" rd /s /q "%BACKUP_DST%"
- if not exist "%BACKUP_DST%" mkdir %BACKUP_DST%
- if not exist "%BACKUP_DST%" goto QUIT
- :COPY_C_BACKUP
- :: Set source on C: drive
- set BACKUP_SRC=C:\AllianceBackup
- if not exist "%BACKUP_SRC%" goto COPY_D_BACKUP
- :: Copy newest Alliance backup from C:\AllianceBackup
- for /f "delims=" %%I in ('DIR %BACKUP_SRC%\*.zip /b /o-d') do xcopy "%BACKUP_SRC%\%%I" "%BACKUP_DST%" /d & goto COPY_D_BACKUP
- :COPY_D_BACKUP
- :: Set srouce on D: drive
- set BACKUP_SRC=D:\AllianceBackup
- if not exist "%BACKUP_SRC%" goto DEL_OLD
- :: Copy newest Alliance backup from D:\AllianceBackup
- for /f "delims=" %%I in ('DIR %BACKUP_SRC%\*.zip /b /o-d') do xcopy "%BACKUP_SRC%\%%I" "%BACKUP_DST%" /d & goto DEL_OLD
- :DEL_OLD
- :: Delete all previous & multiple backups, leave most recent only
- for /f "skip=1 eol=: delims=" %%F in ('dir %BACKUP_DST%\*.zip /b /o-d') do del "%BACKUP_DST%\%%F"
- :QUIT
- del %0
- exit
Advertisement
Add Comment
Please, Sign In to add comment