Backup batch file needed

H

Hans Näslund

I used to have a nice little batch file for my backup, which renamed
yesterday's backup from Backup to Backup1, and the backup from the day
before yesterday from Backup1 to Backup2, and then started the actual
backup.

The batch file was created with the help from some of the computer wizards
here, but silly enough I did not have a backup of it, so when I recently had
a disk crash, the batch file got lost.

May I ask the knowledgeful people here for some help to re-create such a
batch file again?

Hans
 
G

Guest

Personally I would name the backups by date. It is completely up to you
though. Here is an example of how to set the current date and time into
variable if you choose. Let me know if you still want to use your original
way and I'll see what I can come up with for you...

*****lines that don’t begin with 2 space have wrapped accidentally*****

@echo off
setlocal
for /f "tokens=2-4 delims=/ " %%a in ('date /t') do set xdate=%%a-%%b-%%c
for /f "tokens=5-6 delims=:. " %%a in ('echo/^|time^|find "current"') do
set xtime=%%a-%%b
cls
echo.
echo Date - %xdate%
echo.
echo Time - %xtime%
echo.
endlocal
pause

*****lines that don’t begin with 2 space have wrapped accidentally*****

This script just shows you how to get the time and date into a variable. I’m
assuming you know a little about shell scripting to figure the rest out. If
not let me know and I will try to help you further...
 
H

Hans Näslund

Thank you for your reply!

No, I don't want to name the backups by date. Long ago, I used to name them
by weekdays, but when the backups grew too large, my backup disk did not
have room enough for 7 backups, so now I don't want more than 3 backups at
one time.

So what I need is mainly a script for renaming the backups the way I
indicated.
 
H

Hans Näslund

Yes, of course I do - it is BackupPlus, but that is not my issue. The point
for me is to find a simple way of renaming the backups the way I indicated.
 
H

Hans Näslund

I'm trying to find out myself how to do this now.The tricky thing seems to
be to get the renaming right. I have tried this script, but it does not
work - why?

@ECHO OFF
IF EXIST "E:\Normal backup.bac" REN "E:\Normal backup.bac" "E:\Normal
backup1.bac"
IF EXIST "E:\Normal backup.b02" REN "E:\Normal backup.b02" "E:\Normal
backup1.b02"
EXIT
 
P

Pegasus \(MVP\)

When you type

ren /?

then you can see the answer to your problem in the last line:

C:\Temp>ren /?
Renames a file or files.

RENAME [drive:][path]filename1 filename2.
REN [drive:][path]filename1 filename2.

Note that you cannot specify a new drive or path for your destination file.
 
G

Guest

Try:

@ECHO OFF
IF EXIST "E:\Normal backup.bac" REN "E:\Normal backup.bac" backup1.bac
IF EXIST "E:\Normal backup.b02" REN "E:\Normal backup.b02" backup1.b02
EXIT
 
H

Hans Näslund

Thanks a lot to Pegasus and aCkRiTe!

Now my batch file looks like this - and it works!

@ECHO OFF
IF EXIST "E:\Normal backup1.bac" REN "E:\Normal backup1.bac" "Normal
backup2.bac"
IF EXIST "E:\Normal backup1.b02" REN "E:\Normal backup1.b02" "Normal
backup2.b02"
IF EXIST "E:\Normal backup.bac" REN "E:\Normal backup.bac" "Normal
backup1.bac"
IF EXIST "E:\Normal backup.b02" REN "E:\Normal backup.b02" "Normal
backup1.b02"
START "C:\Program\Backup Plus\BackPlus.exe" "C:\Program\Backup Plus\Backup
Sets\Normal backup.bps"
EXIT
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top