Restore Data from Multiple Backup Sets - Examples

If you are using storage groups distributed across multiple SMs so that different storage groups are backed up into different backup-sets, you will need to restore data from multiple backup sets. For more information, see Redundant Hot Copy with Storage Groups.

We use the term backup collection to refer to the multiple backup sets we need to restore from.

In these examples, three separate locations are assumed:

  • /volumes/archives for database archive storage.

  • /volumes/backups for backup storage.

  • /volumes/journals for database journal storage.

Restoring an Archive with Storage Groups

When restoring the database from multiple backup sets to a globally consistent state, XML-based summaries are used as "stand-ins" for backup sets located on remote hosts. Global information available in these XML files enables NuoDB Archive to determine the latest common backup element to be used for the restore.

In this example each SM is backing up to a local /volumes/backups directory on its host. Copying locally is usually faster, but this is not a requirement.

  1. Identify the directory where each backup set in the backup collection is located. In this example, the backup collection contains two backup directories, one on each host at /volumes/backups/BackupSets/2022-04-18.

  2. Using NuoDB Archive's --report-backups command, generate summaries of each backup set. Each summary should be stored in a file. For example:

    On host1:

    nuoarchive restore --report-backups /volumes/backups/BackupSets/2022-04-18 > /tmp/sm1-backupset.xml

    On host2:

    nuoarchive restore --report-backups /volumes/backups/BackupSets/2022-04-18 > /tmp/sm2-backupset.xml
  3. Copy summaries to all hosts involved in the restore so that each summary is available on each host. For example, use scp to copy the summary generated on host1 to host2, and vice versa.

    scp host1:/tmp/sm1-backupset.xml host2:/tmp/
    scp host2:/tmp/sm2-backupset.xml host1:/tmp/
  4. Restore a consistent copy of the archive from each backup set by combining the summaries with each backup set. In the following example, we will restore the backup set on each host to produce a consistent copy of the database consisting of two restored archives on two hosts (host1:/volumes/archives/test2 and host2:/volumes/archives/test2).

    On host1:

    nuoarchive restore --restore-dir /volumes/archives/test2 /volumes/backups/BackupSets/2022-04-18 /tmp/sm2-backupset.xml

    On host2:

    nuoarchive restore --restore-dir /volumes/archives/test2 /volumes/backups/BackupSets/2022-04-18 /tmp/sm1-backupset.xml
  5. Ensure correct ownership. On each machine run:

    sudo chown -R nuodb:nuodb /volumes/archives/test2
  6. Optionally, move the journal to its own volume. If you do this:

    • Check to make sure ownership is still correct.

    • Use --journal-dir when invoking nuocmd create archive.

  7. Start a new database, with SMs serving the restored archives. For example, to start a database named test2 with two SMs serving the restored archives from step 5:

    nuocmd create archive --db-name test2 --restored --archive-path /volumes/archives/test2 --server-id nuoadmin-1
    nuocmd create archive --db-name test2 --restored --archive-path /volumes/archives/test2 --server-id nuoadmin-2
    nuocmd create database --db-name test2 --dba-user ... --dba-password ... --te-server-ids nuoadmin-1 nuoadmin-1

Restore to Specific Backup Elements

When using incremental (or journal) backups, you can restore to a specific element using element IDs.

In this example assume there are two hosts, host1 and host2, corresponding to the Admin Processes (servers) nuoadmin-1 and nuoadmin-2 repectively. The domain looks like this:

nuocmd show domain
server version: 6.0-1-fc6a857de9, server license: Enterprise
server time: 2023-09-08T06:22:06.165012, client token: f37640883d151b9a034970300ceb37ae46fecbad
Servers:
  [nuoadmin-0] host1:48005 [last_ack = 7.57] ACTIVE (LEADER, Leader=nuoadmin-0, log=199574/154/154) Connected *
  [nuoadmin-1] host2:48005 [last_ack = 7.57] ACTIVE (FOLLOWER, Leader=nuoadmin-0, log=199574/154/154) Connected
Databases:
  test [state = RUNNING]
    [SM] host1:48006 [start_id = 10] [server_id = nuoadmin-0] [pid = 640] [node_id = 1] [last_ack = 10.18] MONITORED:RUNNING
    [TE] host1:48007 [start_id = 12] [server_id = nuoadmin-0] [pid = 357] [node_id = 3] [last_ack =  8.08] MONITORED:RUNNING
    [SM] host2:48006 [start_id = 11] [server_id = nuoadmin-1] [pid = 207] [node_id = 2] [last_ack = 10.18] MONITORED:RUNNING
    [TE] host1:48007 [start_id = 13] [server_id = nuoadmin-1] [pid = 291] [node_id = 4] [last_ack =  9.17] MONITORED:RUNNING

To restore to a specific backup element, do the following:

  1. Identify a backup collection to be restored. In this example each SM is backing up to a local /volumes/backups directory on its host. Copying locally is usually faster, but this is not a restriction.

  2. Identify the directory where each backup set in the backup collection is located. In this example, the backup collection contains two backup directories, one on each host at /volumes/backups/BackupSets/2022-04-18.

  3. Using NuoDB Archive's --report-backups command, generate summaries of each backup set. For example:

    On host1:

    nuoarchive restore --report-backups /volumes/backups/BackupSets/2022-04-18 | tee /tmp/sm1-backupset.xml
    <BackupSet id="16df36f3-afb1-bf45-5e87-a6b6d3e44fdf" database="test" databaseId="efa117e7-8b5c-5449-14ab-80f77e81334b" collectionId="fb7f28df-
    405f-488e-b7e4-7307e373be7f" archiveId="9e1a097b-e310-2f4a-38ab-f04f4eaeb1c8">
     <BackupElements>
       <BackupElement id="63bdb6de-5382-459a-8397-c786f16817d4" type="incremental" startDate="2022-04-18 14:20:45" endDate="2022-04-18 14:20:46"/>
       <BackupElement id="4d7338fe-f3c9-4041-aaa1-77ba730807f5" type="journal" startDate="2022-04-18 14:20:37" endDate="2022-04-18 14:20:39"/>
       <BackupElement id="9be268f4-4b11-4913-b7af-cc27bd970d0e" type="incremental" startDate="2022-04-18 14:20:30" endDate="2022-04-18 14:20:31"/>
       <BackupElement id="fb7f28df-405f-488e-b7e4-7307e373be7f" type="full" startDate="2022-04-18 14:20:24" endDate="2022-04-18 14:20:24"/
     </BackupElements>
    </BackupSet>

    On host2:

    nuoarchive restore --report-backups /volumes/backups/BackupSets/2022-04-18 | tee /tmp/sm2-backupset.xml
    <BackupSet id="785ba1e7-9946-8b48-dd9f-d579a5c4fad5" database="test" databaseId="efa117e7-8b5c-5449-14ab-80f77e81334b" collectionId="fb7f28df-
    405f-488e-b7e4-7307e373be7f" archiveId="3203d1ed-2c55-2940-df88-da01c6819cce">
     <BackupElements>
       <BackupElement id="63bdb6de-5382-459a-8397-c786f16817d4" type="incremental" startDate="2022-04-18 14:20:45" endDate="2022-04-18 14:20:46"/>
       <BackupElement id="4d7338fe-f3c9-4041-aaa1-77ba730807f5" type="journal" startDate="2022-04-18 14:20:37" endDate="2022-04-18 14:20:39"/>
       <BackupElement id="9be268f4-4b11-4913-b7af-cc27bd970d0e" type="incremental" startDate="2022-04-18 14:20:30" endDate="2022-04-18 14:20:31"/>
       <BackupElement id="fb7f28df-405f-488e-b7e4-7307e373be7f" type="full" startDate="2022-04-18 14:20:24" endDate="2022-04-18 14:20:24"/>
     </BackupElements>
    </BackupSet>
  4. Copy summaries to all hosts involved in the restore so that each summary is available on each host. For example, use scp to copy the summary generated on host1 to host2, and vice versa:

    scp host1:/tmp/sm1-backupset.xml host2:/tmp/
    scp host2:/tmp/sm2-backupset.xml host1:/tmp/
  5. Restore a consistent copy of the archive from each backup set using the same backup element ID on each host. The following example demonstrates restoring of the backup set on each host to the first incremental backup element ( /volumes/archives/test2 on host1 and /volumes/archives/test2 on host2).

    On host1:

    nuoarchive restore --backup-element-id 9be268f4-4b11-4913-b7af-cc27bd970d0e --restore-dir /volumes/archives/test2 /volumes/backups/BackupSets/2022-04-18 /tmp/sm2-backupset.xml

    On host2:

    nuoarchive restore --backup-element-id 9be268f4-4b11-4913-b7af-cc27bd970d0e --restore-dir /volumes/archives/test2 /volumes/backups/BackupSets/2022-04-18 /tmp/sm1-backupset.xml
  6. Ensure correct ownership. On each host run:

    sudo chown -R nuodb:nuodb /volumes/archives/test2
  7. Optionally, move the journal to its own volume. If you do this:

    • Check to make sure ownership is still correct.

    • Use --journal-dir when invoking nuocmd create archive.

  8. Start a new database, with Storage Managers (SMs) serving the restored archives. For example, to start a database named test2 with two SMs serving the restored archives from step 5:

    nuocmd create archive --db-name test2 --restored --archive-path /volumes/archives/test2 --server-id nuoadmin-1
    nuocmd create archive --db-name test2 --restored --archive-path /volumes/archives/test2 --server-id nuoadmin-2
    nuocmd create database --db-name test2 --dba-user ... --dba-password ... --te-server-ids nuoadmin-1 nuoadmin-1
  9. Now the domain looks like this:

    nuocmd show domain
    server version: 6.0-1-fc6a857de9, server license: Enterprise
    server time: 2023-09-08T06:22:06.165012, client token: f37640883d151b9a034970300ceb37ae46fecbad
    Servers:
      [nuoadmin-0] host1:48005 [last_ack = 4.16] ACTIVE (LEADER, Leader=nuoadmin-0, log=199574/163/163) Connected *
      [nuoadmin-1] host2:48005 [last_ack = 4.16] ACTIVE (FOLLOWER, Leader=nuoadmin-0, log=199574/163/163) Connected
    Databases:
      test [state = RUNNING]
        [SM] host1:48006 [start_id = 10] [server_id = nuoadmin-0] [pid = 640] [node_id = 1] [last_ack = 10.18] MONITORED:RUNNING
        [TE] host1:48007 [start_id = 12] [server_id = nuoadmin-0] [pid = 357] [node_id = 3] [last_ack =  8.08] MONITORED:RUNNING
        [SM] host2:48006 [start_id = 11] [server_id = nuoadmin-1] [pid = 207] [node_id = 2] [last_ack =  9.84] MONITORED:RUNNING
        [TE] host1:48007 [start_id = 13] [server_id = nuoadmin-1] [pid = 291] [node_id = 4] [last_ack =  9.17] MONITORED:RUNNING
      test2 [state = RUNNING]
        [SM] host1:48008 [start_id = 0] [server_id = nuoadmin-0] [pid = 827] [node_id = 1] [last_ack =  9.92] MONITORED:RUNNING
        [TE] host1:48009 [start_id = 2] [server_id = nuoadmin-0] [pid = 831] [node_id = 3] [last_ack =  9.21] MONITORED:RUNNING
        [SM] host2:48008 [start_id = 1] [server_id = nuoadmin-1] [pid = 306] [node_id = 2] [last_ack = 10.05] MONITORED:RUNNING
        [TE] host1:48009 [start_id = 3] [server_id = nuoadmin-1] [pid = 315] [node_id = 4] [last_ack =  9.53] MONITORED:RUNNING