473,574 Members | 2,661 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 4288
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 ENABLEEXTENSION S 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
8990
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 file in a shared folder on a pc connected through a switch to my pc. My wkst uses w2k pro sp4, the other PC win xp home SP1. MSDE 2000. The share...
3
2244
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 file is: D:\MSSQL\BACKUP\MY_DB\MY_DB_ddmmyy.bak
3
6033
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 replace I get this error:
3
5261
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. After initialisation, I tried to restore the old database into the new DB2 version with db2cc or db2 command line interface. The process fails...
0
1888
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 server following command: CREATE DATABASE dbname DEFAULT CHARACTER SET latin5 COLLATE
4
20452
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 backup and no more, then bringing the DB online. I do not want to use a userexit to try and retrieve additional logs - I only want to roll...
0
4078
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 2. Collect the source database tablespace containers’ information <-- db2 list tablespace containers for 0 show detail Then I got as below ...
0
4435
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 LOGARCHMETH1=VENDOR:/usr/tivoli/ tsm/tdp_r3/db264/libtdpdb264.a I make an online backup with include logs to servers local disk and then tranfer backup image...
3
7110
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 restore. If I use the logtarget parameter on the restore db command can I then simply do a rollfoward database to end of logs and stop
0
7815
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7738
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8078
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8257
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7829
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5634
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3766
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2254
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1076
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.