/
Backup and Recovery

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 | IBFILE ] = 'path/backup_name';
time_duration = FROM start_time TO end_time
path = 'absolute_path' or  'relative_path'

Index


Example:

# Directory backup
       BACKUP DATABASE INTO DISK = 'backup_dir_name';
# a single file backup  
       BACKUP DATABASE INTO IBFILE = backup_ibfile_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'
     - File 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 IBFILE = '/home/machbase/backup_20150714.ibf'
# a single table backup
      BACKUP TABLE SYSLOG_TABLE INTO IBFILE = '/home/machbase/backup/syslog_table';


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.

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?

Syntax:

machadmin -r backup_database_path

Example:

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

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


Single Backup File Extraction

Single backup file (IBFILE) can not be used immediately for recovery. After extracting the data with the "machadmin" tool, the backup files are created in the "target_path/backup_file_name/" directory.

Syntax:

machadmin	-x	single_file_backup_file_name	extract_target_path

Example:

Single Backup File Information Confirmation

The single backup file information created by the backup command can be confirmed by machadmin -w command.

Syntax:

machadmin	-w	single_backup_file_name

Example:

machadmin -w ib_backup01
...
Display information of Backup Image successfully.
-----------------------------------------------------------------
     File name        - mach_backup_19700101090000_20150725142017_3
     Create time      - 2015-07-25 14:19:22
     Data duration    - 1970-01-01 09:00:00 ~ 2015-07-25 14:20:17
     Backup duration  - 2015-07-25 14:20:18 ~ 2015-07-25 14:20:18
     Version          - DB(4.0) Meta(1.6) CM(1.5)
---------------------------------------------------------

The displayed information includes the name of the backup file, the date of creation, the start time of the backed up data, the end time, and the version of the backed-up database.

Related content