Managing ObjectStore

osrecovr: Restoring Databases from Archive Logs

The osrecovr utility copies (rolls forward) database modifications from archive log files created by osarchiv to the affected databases. See also Overview of the Backup/Restore Facility.

Syntax

osrecovr [options] [-f backup/log-file...] [pathname_translation...]
-f backup/
log-file...
Specifies an archive log file from which to recover committed database changes made since the last backup.

You can specify the -f option zero, one, or more times. The osrecovr utility processes the files in the order in which you specify them.

If you do not specify the -f option, you must specify the -F option.

You can mix specifications of -f and -F. The osrecovr utility processes them in the order in which you specify them.

Specifying a directory signals an error.

pathname_
translation... 
Specifies a pair of pathnames. The first pathname in the pair indicates the source of the database as recorded in the archive log or backup image. The second pathname indicates the target, that is, the pathname for the database after it is recovered.

You can specify zero, one, or more pathname translations. Each pathname can be a directory or a single database. However, you cannot specify a directory as the source and a database as the target.

If you do not specify at least one pathname_translation, all databases in the archive logs or backup images you specified are restored in their original locations.

Options
-c 
Directs the osrecovr utility to apply each archive log snapshot and each backup image in its own transaction. The default is for all changes to be applied in a single transaction.

-D date 
Specifies a date in MM/DD/YYYY format. The osrecovr utility rolls forward all database changes committed before or on this date. The default is to roll forward to the last snapshot taken.

-F recover-file

Specifies the name of a file that contains a list of archive files or backup images from which to recover specified databases. If you specify "-" as the recover file name, osrecovr reads from standard input.

The list contains one file pathname per line. Leading and trailing white space is ignored.

If you specify the -F option, you can also specify -f with additional file names on the command line. You can mix specifications of -f and -F. osrecovr processes them in the order in which you specify them.

-n 
Normally, if a directory is specified as the source of a recovery operation, all databases in the directory and its subdirectories are recovered. Including the
-n option limits the recovery operation to databases contained in the named directory.

-r time 
Specifies a recover-to time in the HH:MM:SS format. The osrecovr utility rolls forward all database changes committed before or at this time. The default is to roll forward to the last snapshot taken.

-t 
Displays a list of databases contained in specified archive files.

Description

The osrecovr utility can apply changes up to the time of the last snapshot in the archive log or to some earlier time that you specify.

The osrecovr utility can restore backups as well as recover data from archive logs, both in the same invocation.

When you run the osrestore or osrecovr utility, the operation is transaction protected. This means that if the operation fails, ObjectStore rolls databases back to the state they were in before the operation started.

ObjectStore applications cannot access databases that are being restored until the entire restoration process has finished.

Specify a pathname_translation when you want to restore

When restoring data from tape, you must use the osrestore utility.

Run osrestore, then osrecovr

You must run the osrestore utility before the osrecovr utility if you performed both of the following steps:

  1. You used the osbackup utility to back up a database.

  2. You ran the osarchiv utility and used the same incremental backup record that you used for the osbackup utility.

Tradeoffs When Recovering in Several Transactions

You can specify the -c option to recover data in several transactions instead of one transaction. While this gives you flexibility, there is a tradeoff between the ability to roll back databases and the space needed in the log to record all modifications to databases being recovered.

For example, if you specify -c when you initiate osrecovr, ObjectStore recovers each snapshot in its own transaction. If the operation fails because of media failure while applying the last snapshot, ObjectStore rolls the databases back to the state they were in as of the last successfully applied snapshot.

However, suppose that each snapshot is 100 MB. This requires 100 MB of log space. If you ensure that the database does not exist when the recover operation starts, and if you apply all snapshots in a single transaction, all recovered data bypasses the log and goes directly to the database. Now if the operation fails, ObjectStore rolls all changes back, including the database creation.

The fundamental tradeoff is between the ability to roll back to a previous state and the resources needed to log the changes so that rollback is possible. In cases in which the size of the databases being recovered exceeds the size of the space available (or desirable) for logging, it is preferable

Examples

Listing archive contents

% osrecovr -f /vancouver1/archives/1999011216.aaa -t
Recovering from volume #1 (/vancouver1/archives/1999011216.aaa)...
vancouver::/foo.db
vancouver::/dbdir/bar.db
vancouver::/dbdir/foo.db
Closing volume #1 (/vancouver1/archives/1999011216.aaa).
%

Recovering from
a single archive

% osrecovr -f /vancouver1/archives/1999011216.aaa
Recovering from volume #1 (/vancouver1/archives/1999011216.aaa)...
Target time: Tue Jan 12 17:28:22 1999
Recovered to time Tue Jan 12 16:25:27 1999
Recovered to time Tue Jan 12 16:25:57 1999
Recovered to time Tue Jan 12 16:26:11 1999
Restoring 452 sectors to database "vancouver:/vancouver1/dbdir/foo.db"
Recovered to time Tue Jan 12 16:26:41 1999
Recovered to time Tue Jan 12 16:27:13 1999
Recovered to time Tue Jan 12 16:27:43 1999
Recovered to time Tue Jan 12 16:28:14 1999
Closing volume #1 (/vancouver1/archives/1999011216.aaa).
%

Recovering back to place

The next example restores all databases to their location and state as of 16:25:27 and January 12, 1999.

% osrecovr -f /vancouver1/archives/1999011216.aaa -r 16:25:27
Recovering from volume #1 (/vancouver1/archives/1999011216.aaa)...
Target time: Tue Jan 12 16:25:27 1999
Recovered to time Tue Jan 12 16:25:27 1999
Closing volume #1 (/vancouver1/archives/1999011216.aaa).

Recovering from multiple archive files

% cat ./archive_list
/vancouver1/archives/1999011216.aaa
/vancouver1/archives/1999011216.aab
/vancouver1/archives/1999011216.aac
% osrecovr -t -F ./archive_list
Recovering from volume #1 (/vancouver1/archives/1999011216.aaa)...
vancouver::/foo.db
vancouver::/dbdir/bar.db
vancouver::/dbdir/foo.db
Closing volume #1 (/vancouver1/archives/1999011216.aaa).
% osrecovr -F ./archive_list
Recovering from volume #1 (/vancouver1/archives/1999011216.aaa)...
Target time: Tue Jan 12 17:27:01 1999
Recovered to time Tue Jan 12 16:25:27 1999
Recovered to time Tue Jan 12 16:25:57 1999
Recovered to time Tue Jan 12 16:26:11 1999
Restoring 452 sectors to database "vancouver:/vancouver1/dbdir/foo.db"
Recovered to time Tue Jan 12 16:26:41 1999
Recovered to time Tue Jan 12 16:27:13 1999
Recovered to time Tue Jan 12 16:27:43 1999
Recovered to time Tue Jan 12 16:28:14 1999
Closing volume #1 (/vancouver1/archives/1999011216.aaa).
Auto switching to volume #2 (/vancouver1/archives/1999011216.aab).
Recovering from volume #2 (/vancouver1/archives/1999011216.aab)...
Recovered to time Tue Jan 12 16:28:21 1999
Recovered to time Tue Jan 12 16:28:35 1999
Recovered to time Tue Jan 12 16:28:37 1999
Recovered to time Tue Jan 12 16:28:38 1999
Recovered to time Tue Jan 12 16:28:40 1999
Recovered to time Tue Jan 12 16:28:41 1999
Recovered to time Tue Jan 12 16:28:49 1999
Recovered to time Tue Jan 12 16:28:55 1999
Recovered to time Tue Jan 12 16:29:01 1999
Recovered to time Tue Jan 12 16:29:06 1999
Recovered to time Tue Jan 12 16:29:12 1999
Recovered to time Tue Jan 12 16:29:17 1999
Recovered to time Tue Jan 12 16:29:23 1999
Recovered to time Tue Jan 12 16:29:28 1999
Recovered to time Tue Jan 12 16:29:34 1999
Recovered to time Tue Jan 12 16:29:39 1999
Recovered to time Tue Jan 12 16:29:43 1999
Recovered to time Tue Jan 12 16:29:44 1999
Recovered to time Tue Jan 12 16:29:49 1999
Recovered to time Tue Jan 12 16:29:55 1999
Recovered to time Tue Jan 12 16:30:01 1999
Closing volume #2 (/vancouver1/archives/1999011216.aab).
Auto switching to volume #3 (/vancouver1/archives/1999011216.aac).
Recovering from volume #3 (/vancouver1/archives/1999011216.aac)...
Recovered to time Tue Jan 12 16:31:04 1999
Recovered to time Tue Jan 12 16:31:06 1999
Closing volume #3 (/vancouver1/archives/1999011216.aac).
%

Recovering to a date and time

% osrecovr -F ./archive_list -D 1/12/1999 -r 16:27:43
Recovering from volume #1 (/vancouver1/archives/1999011216.aaa)...
Target time: Tue Jan 12 16:27:43 1999
Recovered to time Tue Jan 12 16:25:27 1999
Recovered to time Tue Jan 12 16:25:57 1999
Recovered to time Tue Jan 12 16:26:11 1999
Restoring 452 sectors to database 
"vancouver:/vancouver1/dbdir/foo.db"Recovered to time Tue Jan 12 
16:26:41 1999
Recovered to time Tue Jan 12 16:27:13 1999
Recovered to time Tue Jan 12 16:27:43 1999
Closing volume #1 (/vancouver1/archives/1999011216.aaa).
%

Recovering to a time today

% osrecovr -F ./archive_list -r 16:27:43
Recovering from volume #1 (/vancouver1/archives/1999011216.aaa)...
Target time: Tue Jan 12 16:27:43 1999
Recovered to time Tue Jan 12 16:25:27 1999
Recovered to time Tue Jan 12 16:25:57 1999
Recovered to time Tue Jan 12 16:26:11 1999
Restoring 452 sectors to database "vancouver:/vancouver1/dbdir/foo.db"
Recovered to time Tue Jan 12 16:26:41 1999
Recovered to time Tue Jan 12 16:27:13 1999
Recovered to time Tue Jan 12 16:27:43 1999
Closing volume #1 (/vancouver1/archives/1999011216.aaa).
%

Recovering a single database

The next example makes vancouver::/bar.db equal to vancouver::/foo.db as of 16:27:43 today.

% osrecovr -F ./archive_list -r 16:27:43 vancouver::/foo.db \
vancouver::/bar.db
Recovering from volume #1 (/vancouver1/archives/1999011216.aaa)...
Target time: Tue Jan 12 16:27:43 1999
Recovered to time Tue Jan 12 16:25:27 1999
Recovered to time Tue Jan 12 16:25:57 1999
Recovered to time Tue Jan 12 16:26:11 1999
Recovered to time Tue Jan 12 16:26:41 1999
Recovered to time Tue Jan 12 16:27:13 1999
Recovered to time Tue Jan 12 16:27:43 1999
Closing volume #1 (/vancouver1/archives/1999011216.aaa).
% osls vancouver::/
bar.db
dbdir/
foo.db
%
% cat ./archive_list
/vancouver1/archives/1999011216.aaa
/vancouver1/archives/1999011216.aab
/vancouver1/archives/1999011216.aac
% osrecovr -t -F ./archive_list
Recovering from volume #1 (/vancouver1/archives/1999011216.aaa)...
vancouver::/foo.db
vancouver::/dbdir/bar.db
vancouver::/dbdir/foo.db
Closing volume #1 (/vancouver1/archives/1999011216.aaa).
%

Examples of Recovery Failures

Nonexistent database

% osrecovr -f /vancouver1/archives/1999011216.aaa -r 16:25:27 \
vancouver::/asdla.db vancouver::/as.db
Recovering from volume #1 (/vancouver1/archives/1999011216.aaa)...
Closing volume #1 (/vancouver1/archives/1999011216.aaa).
Recover failed: Database vancouver::/asdla.db does not exist in this 
backup image
%

Day not in
the archives

% osrecovr -F ./archive_list -D 1/11
Recovering from volume #1 (/vancouver1/archives/1999011216.aaa)...
Target time: Mon Jan 11 17:29:08 1999
Closing volume #1 (/vancouver1/archives/1999011216.aaa).
%

Day/year
not in archives

% osrecovr -F ./archive_list -D 1/11/1998
Recovering from volume #1 (/vancouver1/archives/1999011216.aaa)...
Target time: Sun Jan 11 17:29:51 1998
Closing volume #1 (/vancouver1/archives/1999011216.aaa).
%

API

None



[previous] [next]

Copyright © 1999 Object Design, Inc. All rights reserved.

Updated: 03/11/99 11:19:07