Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Name: tonysathre
Dear Mechanix and IVO,
I am working on a batch file that backs up some directories to a file server.
Here's the code:
@echo off
Title Backup Script
cls
set day=%date:~-7,2%
set month=%date:~-10,2%
if %month% equ 01 set days=31
if %month% equ 02 set days=31
if %month% equ 03 set days=28
if %month% equ 04 set days=31
if %month% equ 05 set days=30
if %month% equ 06 set days=31
if %month% equ 07 set days=30
if %month% equ 08 set days=31
if %month% equ 09 set days=31
if %month% equ 10 set days=30
if %month% equ 11 set days=31
if %month% equ 12 set days=30if %day% equ 08 set day=8
if %day% equ 09 set day=9
set /a day=%day%-1
if %day% equ 0 set day=%days%
if %day% lss 10 set day=0%day%echo.
echo.
echo Now executing Nightly Backups
--------------------
echo.
echo.
echo.
echo Moving last nights backup to Retention
--------------------
@echo on
move %1\nightly\%2.zip %1\retention\%day%
@echo off
echo.
echo.
echo.
echo Now doing nightly backup
--------------------
SET PATH=%1
SET PATH=%PATH:"=%
SET PATH=%PATH:"=%
@echo on
C:\WINNT\system32\ntbackup.exe backup "@%PATH%\%2.bks" /n "%2.bkf created %date% at %time%" /d "Set created %date% at %time%" /v:no /r:no /rs:no /hc:off /m normal /j "%2" /l:f /f "%PATH%\nightly\%2.bkf"
@echo off
echo.
echo.
echo.
echo Compressing backup file
--------------------
@echo on
%1\7za.exe a -tzip -mx=9 %1\nightly\%2.zip %1\nightly\%2.bkf
@echo off
echo.
echo.
echo.
echo Copying Nightly Backups
--------------------
@echo on
xcopy /y /s /q "D:\Customer Data\Backup\nightly" l:\backups\nightly
@echo off
echo.
echo.
echo.
echo Moving Retention Backups
--------------------
@echo on
xcopy /y /s /q "D:\Customer Data\Backup\retention" l:\backups\retention
@echo off
echo.
echo.
echo.
echo Removing Backups
--------------------
@echo on
rmdir /q /s "D:\Customer Data\Backup\Nightly\"
rmdir /q /s "D:\Customer Data\Backup\Retention\"
mkdir "D:\Customer Data\Backup\Nightly"
mkdir "D:\Customer Data\backup\Retention"
@echo off
echo.
echo.
echo.
echo Removing uncompressed .bkf file
--------------------
@echo on
del %1\nightly\%2.bkf
@echo off
echo.
echo.
echo.
echo Backup Complete
--------------------What happens after this is done is on the server where the backups are created and compressed (D:\Customer Data\Backup\Nightly, and, D:\Customer Data\Backup\retention\%day% - where %day% is each day of the month, ie, 01, 02, 03, 04 etc... up to 31. I need to change this script so those folders, %day% aren't removed.
This path:
D:\Customer Data\backup\Retention
needs to have 31 folders in it named 01, 02, 03 etc...
Thanks a lot,
tonysathre
UNIX is an operating system, OS/2 is half an operating system, Windows is a shell, and DOS is a boot partition virus.

I don't think I made myself very clear on what I need, so let me rephrase:
The path is D:\Customer Data\Backup\Retention
In the Retention directory there are folders named 01, 02, 03 etc... up to 31. In each of those folders are ZIP files. I need to delete the ZIP files, but not delete the folders they are in.
The way I have the script now, it deletes the ZIP files and the housing folders.
I hope I made myself more clear.
Thanks,
tonysathre
UNIX is an operating system, OS/2 is half an operating system, Windows is a shell, and DOS is a boot partition virus.

Nevermind, I figured it out.
UNIX is an operating system, OS/2 is half an operating system, Windows is a shell, and DOS is a boot partition virus.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |