Database Backup
SQL commands can be used to initiate hot backups, with full, incremental, & differential snapshots, and restorations of schema objects & data within the database.- For the set of SQL commands for database backup, see Database Backup/Restore.
- For a full system backup, see System Backup.
Snapshot Types
Three types of snapshots are supported for database objects & data:- full - snapshot of the given database objects & data
- incremental - snapshot of the changes in the database objects & data since the last snapshot of any kind
- differential - snapshot of the changes in the database objects & data since the last full snapshot
Backup Storage
Database backup files will be transferred to the target specified in the given data sink. There, they will be stored under two levels of directories: the top-level directory will be the name of the database backup and the subdirectory will be the timestamp the snapshot was taken; e.g.:Backup Use Case
A typical usage of the backup feature is:- create a backup, taking an initial full snapshot
- schedule iterative incremental or differential snapshots
- restore a backup
Initial Backup
To create the initial backup, run a CREATE BACKUP statement, in SQL, that specifies:- the name to use for the backup—the backed-up database object set
- the data sink that will be used to transfer the backed-up files to the remote store (e.g., s3)
- the set of database objects to back up
daily_backup- name of the backupbackup_ds- data sink targeting the remote file serviceexample_backup- name of the schema to back up
Create Initial Backup Example
Schedule Iterative Snapshots
To schedule iterative snapshots after the initial backup is done, create a SQL procedure that specifies:- the name of the backed-up database object set (same as the initial backup)
- the data sink that will be used to transfer the snapshots to the remote store (same as the initial backup)
- the schedule for running the incremental snapshots
daily_backup- name of the backup to which snapshots will be addedbackup_ds- data sink targeting the remote file service1 DAY- daily snapshot intervalSTARTING AT...2025-01-01- starting at a date in the past causes the first snapshot to be taken at the next possible time intervalSTARTING AT...00:00:00- schedule the snapshot to be taken at midnight
Schedule Iterative Snapshots Example
Restore Backup
To restore database objects and table data from the latest snapshot in a backup, using the following parameters:daily_backup- name of the backup to restorerestore_ds- data source targeting the remote file serviceexample_backup- name of the schema to restorereplace- any exising database object will be overwritten by its counterpart from the backup
Restore Backup Example