Hi,
db2 v9.5 ese fp2 on Linux I have daily restore script:
Code:
1. db2 force application all
2. sleep 5
3. db2 drop database $DBname
4. db2 terminate
5. db2 "restore database ORIGDB from $BackupDir to $RestoreDir into $DBname logtarget /restore_logs"
6. db2 "rollforward db $DBname to end of logs and stop overflow log path (/restore_logs)"
Note: I have put numbers in this script to easily read output of commands bellow.
The output is:
Code:
1. DB20000I The FORCE APPLICATION command completed successfully.
DB21024I This command is asynchronous and may not be effective immediately.
2. {Note: sleep command does not have output}
3. SQL1035N The database is currently in use. SQLSTATE=57019
4. DB20000I The TERMINATE command completed successfully.
5. SQL2528W Warning! Restoring to an existing database that is the same as the
backup image database, but the alias name "MYDB" of the existing database
does not match the alias "ORIGDB" of backup image, and the database name
"MYDB" of the existing database does not match the database name "ORIGDB" of
the backup image. The target database will be overwritten by the backup
version.
Do you want to continue ? (y/n) SQL2001N The utility was interrupted. The output data may be incomplete.
SQL1035N The database is currently in use. SQLSTATE=57019
This problem appears ones per few days and repeating above script solves the problem.
According to commands output some applications are not forced from database, so drop database command fails. Then when restore is executed restore operation finds out that database already exists (because drop database failed) and asks if restore should overwritten data already included in database.
How should I write script that would force all applications and wait until force application is completed and then execute "drop database"? There is also possible that during force applications new application connects to database, so this also should be prevented.
Regards