The Percona TokuBackup library intercepts system calls that write files and duplicates the writes on backup files. It does this while copying files to the backup directory.
The following technical issues must be addressed to get Percona TokuBackup working with MySQL:
-
The TokuBackup library must be loaded into the mysqld server so that it can intercept system calls. We use LD_PRELOAD to solve the system call intercept problem. Alternatively, the hot backup library can be linked into mysqld.
-
There must be a user interface that can be used to start a backup, track its progress, and determine whether or not the backup succeeded. We use a plugin that kicks off a backup as a side effect of setting a backup session variable to the name of the destination directory.
1 Extract the tarball
2 Copy tokudb_backup.so to MySQL's plugin directory
3 Copy libHotBackup.so to MySQL's lib directory
4 Run mysqld with the TokuBackup library (should exist in the lib directory)
LD_PRELOAD=PATH_TO_MYSQL_BASE_DIR/lib/libHotBackup.so mysqld_safe
NOTE: The preload is NOT necessary for MySQL and MariaDB builds from Percona since we link the TokuBackup library into mysqld already.
5 Install the TokuBackup plugin (should exist in the MySQL plugin directory)
install plugin tokudb_backup soname 'tokudb_backup.so';
Backup to the '/tmp/backup1047' directory. This blocks until the backup is complete.
set tokudb_backup_dir='/tmp/backup1047';
The set tokudb_backup_dir
statement will succeed if the backup was taken. Otherwise, the tokudb_backup_last_error
variable is set.
select @@tokudb_backup_last_error, @@tokudb_backup_last_error_string;
Lets suppose that you want to exclude all 'lost+found' directories from the backup. The tokudb_backup_exclude
session variable contains a regular expression that all source file names are compared with. If the source file name matches the exclude regular expression, then the source file is excluded from the backup.
set tokudb_backup_exclude='/lost\\+found($|/)';
set tokudb_backup_dir='/tmp/backup105';
Percona TokuBackup updates the processlist state with progress information while it is running.
The tokudb_backup_throttle
variable imposes an upper bound on the write rate of the TokuDB backup. Units are bytes per second. Default is no upper bound.
- name:tokudb_backup_plugin_version
- readonly:true
- scope:system
- type:str
- comment:version of the TokuBackup plugin
- name:tokudb_backup_version
- readonly:true
- scope:system
- type:str
- comment:version of the TokuBackup library
- name:tokudb_backup_allowed_prefix
- readonly:true
- scope:system
- type:str
- comment:allowed prefix of the destination directory
- name:tokudb_backup_throttle
- readonly:false
- scope:session
- type:ulonglong
- def_val:18446744073709551615
- min_val:0
- max_val:18446744073709551615
- comment:backup throttle on write rate in bytes per second
- name:tokudb_backup_dir
- readonly:false
- scope:session
- type:str
- comment:name of the directory where the backup is stored
- name:tokudb_backup_last_error
- readonly:false
- scope:session
- type:ulong
- def_val:0
- min_val:0
- max_val:18446744073709551615
- comment:error from the last backup. 0 is success
- name:tokudb_backup_last_error_string
- readonly:false
- scope:session
- type:str
- comment:error string of the last backup
- name:tokudb_backup_exclude
- readonly:false
- scope:session
- type:str
- comment:exclude source file regular expression
TokuBackup is now part of Percona Server. For information about building Percona Server, refer to the corresponding documentation at https://www.percona.com/doc/percona-server/5.6/installation.html#compiling-percona-server-from-source.