The following articles mainly describe the online backup and recovery practices of the DB2 database. If you are curious about the practices of online backup and recovery of the DB2 database, this article will unveil the mystery of this article, the following is a detailed description of the article.
Database, practice, online
Enable online backup
Enable log Archiving
- db2 update db cfg for test using LOGRETAIN ON
Set the log archiving directory
- db2 update db cfg for test using LOGARCHMETH1 DISK:/db2/data/logs
Make an offline backup; otherwise, the DB2 database will not be able to log on.
- db2 backup db test to /db2/data/backup
Online backup
Online backup-the first activity log in the backup log will be backed up to the backup file together)
- db2 backup db test online to /db2/data/backup/ include logs
Online backup-do not back up logs
- db2 backup db test online to /db2/data/backup/
Recover from a backup set containing logs
Restore
- db2 RESTORE db test
- FROM /db2/data/backup taken at 20100514001917 LOGTARGET /db2/data/logs/
Roll Forward
- db2 "rollforward db test to end of logs and stop overflow log path(/db2/data/logs/)"
Note that other archive logs are generated at intervals from the backup success to the DB2 database crash. You can copy these logs to/db2/data/logs, or you can directly roll back from the archive log directory, the same as "Roll Back" in "Backup set recovery without logs ")
Recover a backup set that never contains logs
Restore
- db2 RESTORE db test
- FROM /db2/data/backup taken at 20100514001917
Roll Forward
Db2 "rollforward db test to end of logs and stop overflow log path (/archive log directory /)"