|
Prev: Getting group of data for each member of primary key
Next: When does a stored procedure use an MQT
From: BD on 26 Jun 2008 19:17 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: Dave Hughes on 26 Jun 2008 19:35 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.
From: BD on 27 Jun 2008 12:15 > 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!
|
Pages: 1 Prev: Getting group of data for each member of primary key Next: When does a stored procedure use an MQT |