473,402 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Question: restore from backup in relative path...

BD
Hi there.

Using 8.2 on Windows.

I have a situation where I have a db backup, which I want to deploy to
a group of developer workstations.

The target directory for the database files will be consistent, but
the location that the backup file is on may vary.
I have gone through the entire backup and restore process, and it
works fine.

Where I'm running into an issue is using a relative path for the
location of the backup file.

I would like to use the following:

"db2 restore db NEWDB from %bkupdir% to c: into %dbname% redirect"

....I would then set tablespace containers, CONTINUE the restore, and
then rollforward.

Both 'bkupdir' and 'dbname' are variables which are set in a config
batch file.

I have ECHO set on, and I can see the correct path being displayed
when the restore command echos back after getting the variable names.
But I continually get the 'path for file or device... is not valid'
error message.

Are relative paths workable in this kind of situation?

....the reason I want to use relative paths is that I want to send out
the backup file in the version control software we are using. The path
that the various workstations may have checked out their source into
may vary.

There are other options, I guess - but I'd like to be able to make the
relative path work.

Thanks!!

BD.
Jun 27 '08 #1
2 4263
BD wrote:
Hi there.

Using 8.2 on Windows.

I have a situation where I have a db backup, which I want to deploy to
a group of developer workstations.

The target directory for the database files will be consistent, but
the location that the backup file is on may vary.
I have gone through the entire backup and restore process, and it
works fine.

Where I'm running into an issue is using a relative path for the
location of the backup file.

I would like to use the following:

"db2 restore db NEWDB from %bkupdir% to c: into %dbname% redirect"

...I would then set tablespace containers, CONTINUE the restore, and
then rollforward.

Both 'bkupdir' and 'dbname' are variables which are set in a config
batch file.

I have ECHO set on, and I can see the correct path being displayed
when the restore command echos back after getting the variable names.
But I continually get the 'path for file or device... is not valid'
error message.

Are relative paths workable in this kind of situation?

...the reason I want to use relative paths is that I want to send out
the backup file in the version control software we are using. The path
that the various workstations may have checked out their source into
may vary.

There are other options, I guess - but I'd like to be able to make the
relative path work.

Thanks!!

BD.
From the RESTORE DB reference:

FROM directory/device

The >>>fully qualified<<< path name of the directory or device...

Sorry, but both BACKUP DB and RESTORE DB require absolute paths.
Assuming you're using batch files on Windows 2000 or above (or possibly
XP - I'm a bit fuzzy on the exact versions when some of this
functionality was introduced...) there's a couple of ways around this:

1) Use the %CD% environment variable which expands to the current
working directory. For example:

db2 RESTORE DB NEWDB FROM "%CD%\%BKUPDIR%" TO C: INTO %DBNAME% REDIRECT

2) Alternatively, if BKUPDIR is passed to the batch file on the command
line, you can use the ~f expansion on it. For example, if BKUPDIR is
%1, and DBNAME is %2:

db2 RESTORE DB NEWDB FROM "%~f1" TO C: INTO %2 REDIRECT

CMD extensions need to be enabled for these expansions to work, but
this is the default on WinNT and above (to absolutely guarantee they're
enabled you can use SETLOCAL ENABLEEXTENSIONS at the top of the batch
file). As in the above examples, don't forget to quote these paths in
case the expansions introduce paths containing spaces.
Cheers,

Dave.
Jun 27 '08 #2
BD
1) Use the %CD% environment variable which expands to the current
working directory. For example:

db2 RESTORE DB NEWDB FROM "%CD%\%BKUPDIR%" TO C: INTO %DBNAME% REDIRECT
This %CD% environment variable appears to do the trick. Thanks kindly!
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: emmexx | last post by:
I want to restore a huge database into my workstation. The size of the backup file is more than 6 GB and I don't have enough space on my HD for both the database and the backup file. So I put the...
3
by: butatista | last post by:
Please help SQL Server 2000 Standard I am trying to restore databases on my server and am unable to get them to restore using the database option. For example, the location of my backup...
3
by: Jon Jacobs | last post by:
I attempt to back up a database on one server and restore it on my local machine. This is what the query text looks like: restore database model from Disk='c:\JQJ\mydump\model.bak' with...
3
by: Frank Stefani | last post by:
Hi, due to an upgrade from a former DB2 v7.02, I backed up an entire database to a file in the local filesystem under Linux. I removed the old version completely an installed a fresh v8.1 DB2....
0
by: newman | last post by:
Dear all, I have mysql 4.1.11 on my current server, i need my database restore another server.. (another server mysql version is 4.1.11 same.) And now... I just created new my database to new...
4
by: aj | last post by:
DB2 LUW v8.2 FP 14 RHAS 2.1 I have a DB2 online DB backup that was done w/ the INCLUDE LOGS option. I am interested in restoring that backup, and rolling forward ONLY the logs contained in the...
0
by: zhif | last post by:
I tried to test this process on my personal laptop. Could you help me to take a look where is the problem as below? 1. I created a source database, name: db100 <-- db2 create db db100...
0
by: mitrofun63 | last post by:
Hello. On my production site i have DB2 9.1.2 database configured for archiving logs and making backup through TSM Data Protection for DB2 UDB The LOGARCHMETH1 parameter is set to ...
3
by: Scott | last post by:
Running DB2 9.1 on AIX 5.3 I would like to do a restore of a database from an online backup image to December 21st with a backup that was taken using INLCUDE LOGS Same box, not a redirected...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.