Restoring the DB2® database
Restoring database from offline backup files
An offline backup file is the copy of the entire database and all transactions performed on it at the time when the backup was created. To restore the database, you only need this backup file.
Procedure
- Terminate the connections and deactivate the database.
Note:
TEMADB
is the default database name. If you are unsure whether it applies to your database, see: Checking the database name.db2 terminate db2 deactivate db TEMADB
- Restore the database from the offline backup file.
db2 restore db TEMADB from <location> taken at <timestamp> replace existing
- Upload the software catalog to avoid problems with the data import. At this point, there might be some discrepancies between the server and the contents of the database, which will be resolved after the upload.
Restoring database from online backup files
An online backup file is also the copy of the entire database, but it might not include transactions that were being performed on the database while the backup was being created. Therefore, the backup file must be complemented with archive logs that contain the latest transactions. By choosing the right archive logs, you can either restore the database to the most recent state, or to one of the previous states.
Restoring to the most recent state
To restore the database to the most recent state, use one of your online backup files (preferably, the most recent one), and then apply to it all subsequent archive logs. If you store all archive logs in one directory, the correct ones will be applied automatically.
Procedure
- Terminate the connections and deactivate the database.
Note:
TEMADB
is the default database name. If you are unsure whether it applies to your database, see: Checking the database name.db2 terminate db2 deactivate db TEMADB
- Restore the database from the online backup file.
db2 restore database TEMADB from <location> taken at <timestamp> replace existing
- Restore all archive logs that were saved after the backup
file was created.
db2 rollforward db TEMADB to end of logs and stop log path (/var/archive_logs)
-
Activate the database and restart the BigFix Inventory server to restore its connection to
the database.
db2 activate db TEMADB /etc/init.d/BFIserver restart
- Upload the software catalog to avoid problems with the data import. At this point, there might be some discrepancies between the server and the contents of the database, which will be resolved after the upload.
Restoring to one of the previous states
You can also restore the database to one of the previous states to avoid all subsequent transactions that might have corrupted it. In such a case, you do not apply all archive logs that you store, but only those that are bundled in the backup file. These bundled logs include only transactions from the exact state when the backup was created. You can extract them from the backup file.
Procedure
- Terminate the connections and deactivate the database.
Note:
TEMADB
is the default database name. If you are unsure whether it applies to your database, see: Checking the database name.db2 terminate db2 deactivate db TEMADB
- Extract the transaction logs from the online backup file.
This step is required, because you will not be able to activate the
database unless some logs are applied to it.
db2 restore database TEMADB logs from <online backup file> LOGTARGET /var/extracted_logs/
Note: Ensure that the location for the extracted log files is different from the one in which you store all other archive logs. - Restore the database from the online backup file.
db2 restore database TEMADB from <location> taken at <timestamp> replace existing
- Apply the extracted archive logs.
db2 rollforward database TEMADB to end of logs overflow log path (/var/extracted_logs/)
-
Activate the database and restart the BigFix Inventory server to restore its connection to
the database.
db2 activate db TEMADB /etc/init.d/BFIserver restart
- Upload the software catalog to avoid problems with the data import. At this point, there might be some discrepancies between the server and the contents of the database, which will be resolved after the upload.