How to backup and restore a database in DB2?
In DB2, you can backup and restore databases using either command line tools or graphic interface tools.
backup database:
- To back up a database using the command line tool, you can use the db2backup command with the syntax:
db2backupto
Example: db2backup SAMPLE to /backup - You can back up the database using a graphical user interface tool such as DB2 Control Center or IBM Data Studio. Simply select the database to be backed up, right-click and choose the backup database option, then select the backup path and other options to perform the backup.
Restore Database:
- To restore a database using the command line tool, you can use the db2restore command with the following syntax:
db2restore dbfrom taken at
Example: db2restore db SAMPLE from /backup taken at 20220101120000 - Use graphical interface tools: Choose the database to restore in DB2 Control Center or IBM Data Studio, right-click and select the option to restore the database, then select the backup path and restore point for restoration.