Backup and Recovery

Database Backup

There are two methods of Machbase backup:
  1. Full backup of current DB
  2. Select and backup only specific tables

Syntax:

BACKUP [ DATABASE | TABLE table_name ]  [ time_duration ] INTO [ DISK ] = 'path/backup_name';
time_duration = FROM start_time TO end_time
path = 'absolute_path' or  'relative_path'
BACKUP [ DATABASE | TABLE table_name ] AFTER 'previous_backup_dir'

Example:

# Directory backup
       BACKUP DATABASE INTO DISK = 'backup_dir_name';

# Set backup duration
      - Directory backup
       BACKUP DATABASE FROM TO_DATE('2015-07-14 00:00:00','YYYY-MM-DD HH24:MI:SS')
                         TO TO_DATE('2015-07-14 23:59:59','YYYY-MM-DD HH24:MI:SS')
                         INTO DISK = '/home/machbase/backup_20150714'

When executing the backup command, the backup type, duration condition, and backup destination path must be defined. To back up the entire database, you must specify "DATABASE". To back up specific tables, specify "TABLE" as the backup type. When backing up specific tables, you must specify the table name.

You can specify the backup destination using the DURATION conditional statement. Specify the start time and end time of the backup target data in the FROM and TO clauses. In the example above, "2015-07-14 00:00:00" is defined as FROM and "2015-07-14 23:59:59" is defined as TO, so the user will be able to see all data for July 14, 2015 Quot; Duration If you do not specify a time condition, "1970-01-01 00:00:00" is set to FROM and the current time at which it is executed is set in the TO clause.

The DURATION clause cannot be used in the DATABASE including the tag table and the tag table, and to back up only the added data, you must perform the incremental backup (Backup .... AFTER 'previous_backup') statement.

Specify "IBFILE" to create a backup file as a single file, or "DISK" as a backup option to create multiple files and directories. Note that when specifying a backup path, backup files are created under "$ MACHBASE_HOME / dbs" when a relative path is specified. To specify an absolute path, you must always set a path that starts with "/". 

Database Recovery

When restoring data from a backup file, it can not be executed by a query command, and the command "machadmin -r" should be executed in a situation where the database does not operate. Before running the backup, you should review for the following conditions:

  • Is the Machbase database down?
  • Is the current database deleted and replaced with the data to be recovered, and is the deletion of the current database allowed?
  • For incremental backup, previous full backup file is required.

Syntax:

machadmin -r backup_database_path

Example:

 backup database into disk = '/home/machbase/backup';

 machadmin -k
 machadmin -d
 machadmin -r /home/machbase/backup;