Computing.Net > Forums > Programming > Backup Batch File

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Backup Batch File

Reply to Message Icon

Name: tonysathre
Date: July 19, 2006 at 11:39:23 Pacific
OS: Windows XP Pro SP2
CPU/Ram: P4 2.53 Ghz\ 768 MB
Product: Dell Dimension 4550
Comment:

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=30

if %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.



Sponsored Link
Ads by Google

Response Number 1
Name: tonysathre
Date: July 19, 2006 at 13:04:49 Pacific
Reply:

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.


0

Response Number 2
Name: tonysathre
Date: July 19, 2006 at 13:29:19 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Backup Batch File

Batch file help www.computing.net/answers/programming/batch-file-help/14346.html

batch filing www.computing.net/answers/programming/batch-filing/11780.html

Batch File - controled backup www.computing.net/answers/programming/batch-file-controled-backup/14024.html