- 데이터베이스 백업
- 데이터베이스 복구
- 단일 백업 파일 추출
- 단일 백업 파일의 정보 확인
데이터베이스 백업
마크베이스의 백업 방법은 두가지가 있다.
1. 현재 DB의 전체 백업
2. 특정 테이블만 선택해서 백업
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';
백업 명령을 실행할 때, 백업 타입과 duration 시간 조건절, 백업 대상 path를 반드시 정의하여야 한다. 전체 데이터베이스를 백업하려면 "DATABASE"를, 특정 테이블을 백업하려면 "TABLE"을 백업 타입에 지정하고, 특정 테이블을 백업할 때에는 테이블 이름을 지정하여야 한다.
DURATION조건절을 이용하여 백업 대상을 지정할 수 있다. 백업 대상 데이터의 시작 시간과 끝 시간을 FROM및 TO절에서 지정한다. 위 예제에서 "2015-0714 00:00:00" 가 FROM으로 정의되었고, "2015-07-14 23:59:59" 이 TO로 정의되었으므로, 사용자는 2015년 7월 14일의 전체 데이터를 백업하는 것이다. time duration절에 아무 것도 정의되어 있지 않다면 "1970-01-01 00:00:00" 이 FROM으로 설정되고 실행되는 현재 시점이 TO절에 설정된다.
In the case of example above, "2015-0714 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 as 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:
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.