I assume you are trying to take an OFFLINE backup. You can use db2 FORCE APPLICATION ALL
. As listed in the manual:
ALL - All applications will be disconnected from the database server.
Though before you take the force route - I suggest taking a look at QUIESCE
instead or properly stopping the application. Your backup process would look something like this:
# Stop your application
su - db2inst1 # Or whatever instance you have
timestamp=$(date +%Y-%m-%d-%H-%M)
mkdir backup-mydb-$timestamp
# Connect to your database and check existing connections
db2 CONNECT TO MYDB;
db2 list applications for database MYDB show detail
# QUISCE the database
db2 QUIESCE DATABASE IMMEDIATE FORCE CONNECTIONS;
db2 CONNECT RESET
# Perform the backup
db2 BACKUP DATABASE MYDB TO "/home/db2i2/backup-mydb-$timestamp" WITH 2 BUFFERS BUFFER 1024 PARALLELISM 1 WITHOUT PROMPTING;
# UNQUISCE the database
db2 CONNECT TO MYDB
db2 UNQUIESCE DATABASE;
db2 CONNECT RESET;
# Test the backup
db2ckbkp -h backup-mydb-$timestamp/*
# Start your application
You can also use db2top
to monitor database connections and identify what applications you need to stop.