Restore Data From Backup Sets
A simple hot copy creates an identical copy of the archive copied, which can be used directly to start a new SM - see here for details.
In all other cases, hot copy backs up into backup sets. A backup set is the directory created when initiating a full hot copy. For more background on backup sets, see Using Backup Sets.
-
To use the data hot copied into backup sets, it must be restored into a new database archive using
nuoarchive
.
Important Considerations
Be aware of the following:
-
nuoarchive restore
is an offline operation. -
Do not restore into any archive of a running database.
-
Neither the source backup set nor the target archive(s) can be in use by a running database.
-
-
nuoarchive restore
creates a new archive and you can then use this archive:-
To start a new SM for the same database the hot copy came from.
-
To restart an SM on an existing host that has been offline for a long time (to reduce archive synchronization time).
-
To create a new database (a copy of the original).
-
-
In the event of lost or corrupted data due to an application or human error:
-
Create a brand new database by restoring to a point-in-time just before the error happened.
-
Then use SQL to copy the lost or corrupted data from the new, restored database back to the original database.
-
-
Ensure the correct ownership of the restored archive directory and its contents.
-
root
user access orsudo
elevated permissions access are required to perform this task:-
Bare metal/VM: Run
chown nuodb:nuodb <dir>
-
In a Container: Permissions should be set for you, but if necessary run
chown nuodb:root <dir>
(note the group isroot
notnuodb
). -
See also the restore Helm chart which can automate this process under Kubernetes.
-
-
-
The journal(s) will be found in a subdirectory of the restored archive. You may wish to move them to a separate directory (typically to their own volume).
-
If so, ensure the same ownership as above for the journal directory and its contents.
-
Use
--journal-dir
to specify its location when runningnuocmd create archive
.
-
-
If using storage groups you will probably need to restore from multiple backup sets in order to restore all storage groups. NuoDB does not track this and you need to know which backup sets, from which SMs, contain which storage groups.
-
One solution is to incorporate the storage group names in the backup set names, for example:
testdb-2022-09-21-archive-0-sg1-sg2
.
-
For more information on backup sets and journals, see Using Backup Sets.
Performing a Restore
In the descriptions below, "using a backup" means using one or more backup sets to restore an archive (depending on whether you are using storage groups or not).
The basic steps are:
-
Restore from a backup to create a new archive, repeat for multiple hosts (multiple SMs) as desired.
-
On each host:
-
Optionally copy the journal to its own volume.
-
Ensure correct ownership of the archive and journal.
-
Initialize each archive using
nuocmd create archive … --restored
-
-
Start the SM process(es):
-
Explicitly using
nuocmd start process
(existing database) on each host. -
Or by using
nuocmd create database
(new database).
-
See [worked-examples] below for examples of performing step 1 (the restore).
Restoration Scenarios
Why might you restore from a backup?
- Creating a New Database
-
-
Use a backup to create a copy of the original database. Restore the archive on the first SM host, then copy it to all the other new SM hosts.
-
As (1) but restore from backup to a specific point-in-time or to a specific backup-element.
-
- New SM for an Existing Database
-
To reduce archive SYNC time, restore the archive from latest backup and use this to initialize the SM. The SM need only SYNC changes since the backup was taken.
- Restoring a Failed SM
-
If an SM has failed due to a disk or other hardware error. Once fixed, use the latest backup to restore its archive (essentially the same scenario as the previous case).
- Restoring a Database to a Known State
-
Stop the existing database, restore from the backup and use it to replace the archive and journal on every SM host, then restart the database.
Restoring a Database to a Specific Known State
This can only be done by taking the database offline and replacing its archives and journals. However, if you are careful, it can be done without deleting the database and recreating it. This is typically not a production requirement, but is often needed during development and testing. Possibile scenarios:
-
Doing a globally consistent restore using locally available backup sets.
-
This is required if using Storage Groups - see [restore-multiple-backup-sets].
-
-
Doing a local restore on one host and relying on that host syncing other newly started SMs.
-
All SMs but the first will start with an empty archive and journal, and so must SYNC from the first.
-
-
Doing a local restore on one host and copying the archive to seed other SMs (to avoid syncing overhead).
-
Restore on one host to the exact state required and starting the SM on it.
-
Then do a local restore on the other hosts to seed them and allow them to sync with the first SM.
-
Since they all have the exact same archive and journal, syncing will be minimal.
-
Steps required for a local restore:
-
Restore an archive to a temporary directory using any of the techniques described in this section.
-
Shutdown the database and replace all its archives and journals with the restored archive and its journal.
-
How to do this is described under simple hot copy - note the warning in this section.
-
-
Restart the database.
As this is most commonly required for development and/or testing, we suggest the following approach for creating the necessary backup:
-
Create your database and populate it with the desired data.
-
To take the backup:
-
Stop all clients so no changes to the database can occur.
-
Perform a simple hot copy on any host, multiple hosts if using storage groups.
-
-
Retain the backup(s) until needed.