- Backup a Database
- Restore a Database
- Extract as a single file
- Retrieve information of a single backup file
Backup a Database
Machbase offers two options for backing up your data.
...
- 데이터베이스 백업
- 데이터베이스 복구
- 단일 백업 파일 추출
- 단일 백업 파일의 정보 확인
데이터베이스 백업
마크베이스의 백업 방법은 두 가지가 있다.
1. 현재 DB의 전체 백업
2. 특정 테이블만 선택해서 백업
Syntax:
Code Block | ||
---|---|---|
| ||
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' |
...
Code Block |
---|
# Directory backup BACKUP DATABASE INTO DISK = 'backup_dir_name'; # a single file backup BACKUP DATABSEDATABASE 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.Example:
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-0714 00:00:00" is set in FROM and 백업 명령을 실행할 때, 백업 타입과 duration 시간 조건절, 백업 대상 경로를 반드시 정의하여야 한다. 전체 데이터베이스를 백업하려면 "DATABASE"를, 특정 테이블을 백업하려면 "TABLE"을 백업 타입에 지정하고, 특정 테이블을 백업할 때에는 테이블 이름을 지정하여야 한다.
DURATION 조건절을 이용하여 백업 대상을 지정할 수 있다. 백업 대상 데이터의 시작 시간과 끝 시간을 FROM 및 TO 절에서 지정한다. 위 예제에서 "2015-07-14 00:00:00" 가 FROM으로 정의되었고, "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, 이 TO로 정의되었으므로, 사용자는 2015년 7월 14일의 전체 데이터를 백업하는 것이다. 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 이 FROM으로 설정되고 실행되는 현재 시점이 TO절에 설정된다.
백업 파일을 단일 파일로 생성하려면 "IBFILE"을, 여러개의 파일과 디렉터리로 생성하려면 "DISK"를 백업 옵션에 지정한다. 백업 경로를 지정할 때, 상대 경로를 지정하면 "$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:
...
아래에 백업 파일들이 생성되므로 주의하여야 한다. 절대 경로를 지정하려면 항상 "/"로 시작하는 경로를 설정하여야 한다.
데이터베이스 복구
백업 파일에서 데이터 복원을 수행할 때는 질의 명령으로 수행할 수 없으며, "machadmin -r" 명령을 데이터베이스가 동작하지 않는 상황에서 실행해야 한다. 백업 실행 이전에 다음의 조건들을 검토해야 한다.
- 마크베이스 데이터베이스가 정지 상태인가
- 현재의 데이터는 삭제되고 복구할 데이터로 대치되므로, 현재 데이터베이스의 삭제가 허용되는가
Syntax:
Code Block |
---|
machadmin -r backup_database_path |
...
Code Block |
---|
backup database into disk = '/home/machbase/backup'; machadmin -k machadmin -d machadmin -r /home/machbase/backup; |
Extract as a Single File
...
단일 백업 파일 추출
단일 백업 파일(IBFILE)은 바로 복구에 사용할 수가 없으며, 복구 이전에 반드시 추출 과정으로 디렉터리 백업 형태로 전환하여야 한다. "machadmin" 도구로 데이터를 추출하고 나면 백업 파일들은 "target_path/backup_file_name/" directory디렉터리에 생성된다.
Syntax:
Code Block |
---|
machadmin -x single_file_backup_file_name extract_target_path |
Example:
Retrieve Information of a Single Backup File
...
단일 백업 파일의 정보 확인
백업 명령으로 생성한 단일 백업 파일의 정보는 machadmin -w 명령으로 확인할 수 있다.
Syntax:
Code Block |
---|
machadmin -w single_backup_file_name |
...
Code Block |
---|
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표시된 정보는 백업 파일의 이름, 생성 날자, 백업된 데이터의 시작 시간, 마지막 시간, 그리고 백업된 데이터베이스의 버전이 표시된다.