cancel
Showing results for 
Search instead for 
Did you mean: 

Database Recovery: Using Old Backup File and remote databases

Former Member
3,849

I had a hard-drive failure recently where I lost the database and transaction log.

Unfortunately we did not have a robust backup strategy and the most recent backup was about a week old.

I'm wondering the best strategy to recover the database, and the missing weeks worth of data, by using the remote database(s) and/or transaction logs. * The main problem is that most of the remotes had replicated data during the last week of the database's life and therefore have confirmed received offsets that are newer than what the restored database expects. (DBREMOTE reports "Message does not belong to me...")

We only have 7 or so remote sites, which have similar but different subscriptions. So its not like I have to reconcile hundreds of remotes, however I do not have direct access to the databases but could setup a remote connection if necessary.

We are using SQL Remote 8.03 over FTP. There were multiple clients that had run dbremote between the date of the old backup (July 25) and the date of the database crash (July 30).

I know that I could use the "old" backup and then re-extract all the clients, which would get all the offsets in sync, however that would mean that a weeks of data would be lost.

Should I use the remote transaction files and extract the SQL ?

Is there a way to use the FTP messages on the server that were not picked up to restore data ? (some clients had not replicated in a while)

I am not averse to using undocumented procedures to reconcile the expected sent/confirmed etc values.

thanks, michael

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member

I don't think there are any automated ways to recover the consolidated database from all the remote databases even after you fixed all the offset problems, because dbremote will not send any operations back to the subscriber, if the operations originally were coming from the subscriber. However, you may be able to recover part or all of the data from the transaction log files of all the remote databases manually, assuming the transaction log files of the remote databases have not been deleted. Here are the steps:

  1. Run dblog against the backup consolidated database, dblog will generate something like

    Transaction log starting offset is O1

    SQL Remote truncation offset is T1

    Transaction log current relative offset is O2

    (Please don't try to start the database, because it would change the end log offset of the database). Then add O1 and O2 together that is the end log offset of the backup consolidated database;

  2. Go to a remote site and shutdown the remote database engine;
  3. Make a directory, say logs and copy all the transaction log files including the online transaction log to this newly created directory;
  4. Run dbtran against this directory using the following command line:

    dbtran -sr -is sr -y -m full_pathlogs -n my.sql

    Dbtran will retrieve the operations that were applied by dbremote from all the log files stored in full_pathlogs and save these operations to my.sql;

  5. Edit my.sql and look for the lines with the following style:

    --REMOTE-1016-0000439055-0102-RECEIVED-NA-0000443759

    In this line,

    1016: 16 is a connection ID;

    0000439055: current offset in the remote transaction log;

    0102: current user ID;

    0000443759: the commit offset in the subscriber's database.

    In this example, all the operations before this line in the my.sql file came from the subscriber with log offset less than 0000443759. Then remove all the operations that have already in the consolidated database from my.sql.

Then repeat steps 2) to 5) for each remote database. After you have the my.sql files from all the remote sites, you may need to check if they contain any duplicate data. If there are not, then apply all my.sql against the consolidated database and then re-extract all the remotes.

Please try these steps on the test environment first.