Backup and Restore

Table of Contents

Backup a Database

Machbase offers two options for backing up your data.

  1. DATABASE backup is to back up the information of active DB.
  2. TABLE backup is to back up a selected table.

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'

Example:

# Directory backup
       BACKUP DATABASE INTO DISK = 'backup_dir_name';
# a single file backup  
       BACKUP DATABSE 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 backing up a database, types of backup, time duration and location must be inserted. If you want to backup the entire database, insert "DATABASE" as backup type. If you want to back up a specified table, enter "TABLE" and a table name.

With time_duration syntax, you can set a particular period of time for backup. You can select and back up the data by setting up the starting time and date in FROM and the ending time and date in TO part. In the case of example above, "2015-07-14 00:00:00" is set in FROM and "2015-07-14 23:59:59" in TO from time_duration syntax so that the user can back up the data for 14th of July in 2015. If none is specified for time_duration, "1970-01-01 00:00:00" will be applied to FROM and the time when you are executing the command will be applied TO.

Now, you need to select the storage medium for backup results. If you want to create the backup with a single file, set to "IBFILE" and set to "DISK" if you want to create it as directory. Caution should be exercised when setting up the path for the backup storage. That is, if you set a relative path, the path will be created in "$MACHBASE_HOME/dbs" of database environments which is currently running. If you want to store the data in other locations rather than "$MACHBASE_HOME/dbs", it is required to type in the absolute path starting with "/" symbol.

Restore a Database

Database restoration cannot be provided as statements, rather it can restore data via "machadmin -r" from an offline. Check the followings before the restoration:

  • Check whether the Machbase process is shutdown.
  • Check whether the existing database deleted.

Syntax:

machadmin -r backup_database_path;

Example:

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

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

Extract a Single File

A single backup file in INTO IBFILE format cannot be restored right away during the process of backup. It is required to convert the data into directory format by using "machadmin".
After the conversion, backup files are created in the "target_path/backup_file_name/"directory.

Syntax:

machadmin -x single_file_backup_file_name extract_target_path

Example:

machadmin -x backup_20150101.ibf /db/data/
machadmin -r /db/data/backup_20150101.ibf/

Retrieve Information of a Single Backup File

The information of a single backup file can be retrieved using machadmin -w command.

Syntax:

machadmin -w single_backup_file_name

Example:

machadmin -w ib_backup01
-----------------------------------------------------------------
     Machbase Administration Tool
     Release Version - 3.0.0 official
     Copyright 2014, Machbase Inc. or its subsidiaries
     All Rights Reserved
-----------------------------------------------------------------
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 are name of backup file, date of creation, the starting point of backup file to backup, the ending point of backup file to ends the backup operation, and the current version of the database. Machbase offers two options for backing up your data.

results matching ""

    No results matching ""