Enabling automatic backup

A database can become unusable due to a wide variety of hardware or software failures. Ensuring that you have a recent, full backup of your database is an integral part of planning and implementing a disaster recovery strategy for your system. Use automatic database backup as part of your disaster recovery strategy to enable Db2® to back up your database both properly and regularly.

About this task

You can configure automatic backup using the command line interface, or the AUTOMAINT_SET_POLICY system stored procedure. You also need to enable the health indicator db.db_backup_req, which by default is enabled. Note that only an active database is considered for the evaluation.

Procedure

  • Set the following database configuration parameters to ON:
    • AUTO_MAINT
    • AUTO_DB_BACKUP
  • To configure automatic backup usingIBM® Data Studio, right-click the database and select the task assistant to configure automatic backup.
  • To configure automatic backup using the AUTOMAINT_SET_POLICY system stored procedure:
    1. Configure the automatic backup policy:
      • Create configuration XML input that specifies details like backup media, whether the backup should be online or offline, and frequency of the backup. Note, if ONLINE backup is specified, then log archiving needs to be enabled.

        You can copy the contents of the sample file called DB2DefaultAutoBackupPolicy.xml into the SQLLIB/samples/automaintcfg directory and modify the XML to satisfy your configuration requirements.

      • Optional: Create an XML input file containing your configuration XML input.
      • Call AUTOMAINT_SET_POLICY with the following parameters:
        • maintenance type: AUTO_BACKUP
        • configuration XML input: either a BLOB containing your configuration XML input text; or the name of the file containing your configuration XML input.
    2. Configure the automatic maintenance policy:
      • Create configuration XML input that specifies details like the online and offline window of the database.

        You can copy the contents of the sample file called DB2MaintenanceWindowPolicySample.xml into the SQLLIB/samples/automaintcfg directory and modify the XML to satisfy your configuration requirements.

      • Optional: Create an XML input file containing your configuration XML input.
      • Call AUTOMAINT_SET_POLICY with the following parameters:
      • maintenance type: MAINTENANCE_WINDOW
      • configuration XML input: either a BLOB containing your configuration XML input text; or the name of the file containing your configuration XML input.
    3. Reactivate the database:
      • db2 deactivate db <dbname>
      • db2 activate db <dbname>