1.

Solve : Backup a couple of directories using a batch file?

Answer»

Hello guys!

First of all - sorry if this has been asked before (I did search but probably just couldn't figure out the right terms to use) and also sorry if what I'm about to ask is stupid-simple to create, but unfortunately my level of experience in DOS isn't that big - I only know a few basic commands, and some basic knowledge from Unix shell.

OK. So I backup daily a couple of directories by zipping them onto my Flash Drive, without deleting the old files, but instead adding a following (+1) number to the name of the zip archive.

So I was wondering, since after a few hundred of these operations it gets REALLY irritating, is there a way to automate that task with a batch FILE, that I would only have to click on and it will do the REST for me (well, that's actually a RHETORICAL question - I'm pretty sure a simple operation as this is perfectly possible, I'm just too dumb to know how).

Thank you all guys!You just need to use XCOPY and since your copying it onto your Flash drive, I suggest just storing the batch file on the drive.

Code: [Select]@echo off
if not EXIST BackupBat.inf (echo. 1 > BackupBat.inf)
for /f %%a in (BackupBat.inf) do (
rd Backup%%a
set /a count=%%a+1
md Backup%count%
)
del BackupBat.inf
echo. %count% > BackupBat.inf
xcopy "C:\SourceDir\*.*" "Backup%count%" /E
echo.Backup Done
pause
NOTE:This will create a seperate file to keep track of the Backup Count, if this file is Deleted then it'll rewrite the First backup folder made.

Hope this helps
,Nick(macdad-)Thanks Nick!

It works, but it's not quite what I had in mind.

I have these directories:

E:\SomeDir
E:\SomeOtherDir

And I want to do the following with them:

ZIP E:\SomeDir to X:\backup\SomeDir112.zip
ZIP E:\SomeOtherDir to X:\backup\SomeOtherDir112.zip

Then the next time I do it it'll be X:\backup\SomeDir113.zip & X:\backup\SomeOtherDir113.zip and so on.Oh the ZIP command

Atleast you found the slip-up OK. Sorry for reopening this and bothering you again, but I've been trying to find out how to install a ZIP compressor for DOS and I just can't find anything.There are some compressors/decompressors that work from the command-line. Quote from: Helpmeh on October 18, 2009, 06:07:13 AM

There are some compressors/decompressors that work from the command-line.
Can you tell me how to find out if I have any and how to execute them?Google for 7-zip
Quote from: Salmon Trout on October 18, 2009, 09:43:58 AM
Google for 7-zip


Thanks a lot mate! That worked truly great!!! Problem with backup is solved now!


Discussion

No Comment Found