Create the Data to Backup
Before you can back up data, you need to create a database with a table and populate it with the data. Use the DB2 Command Line Processor to create your database:
db2 => create db backdem
Next, connect to the database you just created:
db2 => connect to backdem user db2admin using db2admin
Next, create a simple table consisting of three columns. Table 1 shows the structure and sample data you'll store inside the table.
|SuperHeroName (Varchar 45) *
||SuperHeroIdentity (Varchar 45)
Table 1: Structure and Sample Data Values for secretidentities Table
To create your table, use the following command:
db2 => create table secretidentities(superheroname varchar(45) primary key not null,
superheroidentity varchar(45) not null)
Use the following syntax to populate the first row in Table 1:
db2 => insert into secretidentities values (Superman,Clark Kent)
Repeat the command to populate the table with the other two rows.
Backup! Backup! Backup!
Now back up your database. The following command backs up the database
backdem to the directory
db2 => backup database backdem user db2admin using db2admin to c:\dbback
After issuing this command, you should receive a prompt similar to the following:
Backup successful. The timestamp for this backup image is: 20031119181253.
The timestamp uniquely identifies each database backup. You should make note of it so you can later specify the database backup from which you want to restore.
You can also use the DB2 Control Center to perform your backup. Just right click on the database you want to backup and choose the "Backup" option from the context menu as shown in Figure 1.
|Figure 1: Using the Control Center to Backup|
The resulting DB2 backup wizard helps you create a backup task via a graphical interface (see Figure 2).