Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
A comprehensive reference for all command-line options available in mariadb-backup, covering backup, prepare, and restore operations.
mariadb-backup Options--apply-logPrepares an existing backup to restore to the MariaDB Server. This is only valid in innobackupex mode, which can be enabled with the option.
Files that mariadb-backup generates during operations in the target directory are not ready for use on the Server. Before you can restore the data to MariaDB, you first need to prepare the backup.
In the case of full backups, the files are not point in time consistent, since they were taken at different times. If you try to restore the database without first preparing the data, InnoDB rejects the new data as corrupt. Running mariadb-backup with the command readies the data so you can restore it to MariaDB Server. When working with incremental backups, you need to use the --prepare command and the option to update the base backup with the deltas from an incremental backup.
Once the backup is ready, you can use the or the commands to restore the backup to the server.
--apply-log-onlyIf this option is used when preparing a backup, then only the redo log apply stage are performed, and other stages of crash recovery are ignored. This option is used with incremental backups.
Note: This option is not needed or supported anymore.
--backupBacks up your databases.
Using this command option, mariadb-backup performs a backup operation on your database or databases. The backups are written to the target directory, as set by the option.
mariadb-backup can perform full and incremental backups. A full backup creates a snapshot of the database in the target directory. An incremental backup checks the database against a previously taken full backup, (defined by the option) and creates delta files for these changes.
In order to restore from a backup, you first need to run mariadb-backup with the --prepare option, to make a full backup point-in-time consistent or to apply incremental backup deltas to base. Then you can run mariadb-backup again with either the or commands to restore the database.
For more information, see and .
--binlog-infoDefines how mariadb-backup retrieves the binary log coordinates from the server.
The --binlog-info option supports the following retrieval methods. When no retrieval method is provided, it defaults to AUTO.
Using this option, you can control how mariadb-backup retrieves the server's binary log coordinates corresponding to the backup.
When enabled, whether using ON or AUTO, mariadb-backup retrieves information from the binlog during the backup process. When disabled with OFF, mariadb-backup runs without attempting to retrieve binary log information. You may find this useful when you need to copy data without metadata like the binlog or replication coordinates.
Currently, the LOCKLESS option depends on features unsupported by MariaDB Server. See the description of the file for more information. If you attempt to run mariadb-backup with this option, then it causes the utility to exit with an error.
--close-filesDefines whether you want to close file handles.
Using this option, you can tell mariadb-backup that you want to close file handles. Without this option, mariadb-backup keeps files open in order to manage DDL operations. When working with particularly large tablespaces, closing the file can make the backup more manageable. However, it can also lead to inconsistent backups. Use at your own risk.
--compressThis option was deprecated as it relies on the no longer maintained library. It are removed in a future release - versions supporting this function will not be affected. It is recommended to instead backup to a stream (stdout), and use a 3rd party compression library to compress the stream, as described in .
Defines the compression algorithm for backup files.
The --compress option only supports the now deprecated quicklz algorithm.
If a backup is compressed using this option, then mariadb-backup will record that detail in the file.
--compress-chunk-sizeDeprecated, for details see the option.
Defines the working buffer size for compression threads.
mariadb-backup can perform compression operations on the backup files before writing them to disk. It can also use multiple threads for parallel data compression during this process. Using this option, you can set the chunk size each thread uses during compression. It defaults to 64K.
To further configure backup compression, see the and options.
--compress-threadsDeprecated, for details see the option.
Defines the number of threads to use in compression.
mariadb-backup can perform compression operations on the backup files before writing them to disk. Using this option, you can define the number of threads you want to use for this operation. You may find this useful in speeding up the compression of particularly large databases. It defaults to single-threaded.
To further configure backup compression, see the and options.
--copy-backRestores the backup to the data directory.
Using this command, mariadb-backup copies the backup from the target directory to the data directory, as defined by the --datadir option. You must stop the MariaDB Server before running this command. The data directory must be empty. If you want to overwrite the data directory with the backup, use the --force-non-empty-directories option.
Bear in mind, before you can restore a backup, you first need to run mariadb-backup with the --prepare option. In the case of full backups, this makes the files point-in-time consistent. With incremental backups, this applies the deltas to the base backup. Once the backup is prepared, you can run --copy-back to apply it to MariaDB Server.
Running the --copy-back command copies the backup files to the data directory. Use this command if you want to save the backup for later. If you don't want to save the backup for later, use the --move-back option.
--core-fileDefines whether to write a core file.
Using this option, you can configure mariadb-backup to dump its core to file in the event that it encounters fatal signals. You may find this useful for review and debugging purposes.
--databasesDefines the databases and tables you want to back up.
Using this option, you can define the specific database or databases you want to back up. In cases where you have a particularly large database or otherwise only want to back up a portion of it, you can optionally also define the tables on the database.
In cases where you want to back up most databases on a server or tables on a database, but not all, you can set the specific databases or tables you don't want to back up using the --databases-exclude option.
If a backup is a partial backup, then mariadb-backup will record that detail in the xtrabackup_info file.
In innobackupex mode, which can be enabled with the --innobackupex option, the --databases option can be used as described above, or it can be used to refer to a file, just as the can in the normal mode.
--databases-excludeDefines the databases you don't want to back up.
Using this option, you can define the specific database or databases you want to exclude from the backup process. You may find it useful when you want to back up most databases on the server or tables on a database, but would like to exclude a few from the process.
To include databases in the backup, see the --databases option option.
If a backup is a partial backup, then mariadb-backup records that detail in the xtrabackup_info file.
--databases-fileDefines the path to a file listing databases and/or tables you want to back up.
Format the databases file to list one element per line, with the following syntax:
In cases where you need to back up a number of databases or specific tables in a database, you may find the syntax for the --databases and --databases-exclude options a little cumbersome. Using this option you can set the path to a file listing the databases or databases and tables you want to back up.
For instance, listing the databases and tables for a backup in a file called main-backup:
If a backup is a partial backup, mariadb-backup records that detail in the xtrabackup_info file.
-h, --datadirDefines the path to the database root.
Using this option, you can define the path to the source directory. This is the directory that mariadb-backup reads for the data it backs up. It should be the same as the MariaDB Server datadir system variable.
--debug-sleep-before-unlockThis is a debug-only option used by the Xtrabackup test suite.
--decompressDeprecated, for details see the --compress option.
This option requires that you have the qpress utility installed on your system.
Defines whether you want to decompress previously compressed backup files.
When you run mariadb-backup with the --compress option, it compresses the subsequent backup files, using the QuickLZ algorithm. Using this option, mariadb-backup decompresses the compressed files from a previous backup.
For instance, run a backup with compression:
Then, decompress the backup:
You can enable the decryption of multiple files at a time using the --parallel option. By default, mariadb-backup does not remove the compressed files from the target directory. To delete these files, use the --remove-original option.
--debug-syncDefines the debug sync point. This option is only used by the mariadb-backup test suite.
--defaults-extra-fileDefines the path to an extra default option file.
Using this option, you can define an extra default option file for mariadb-backup. Unlike --defaults-file, this file is read after the default option files are read, allowing you to only overwrite the existing defaults.
--defaults-fileDefines the path to the default option file.
Using this option, you can define a default option file for mariadb-backup. Unlike the --defaults-extra-file option, when this option is provided, it completely replaces all default option files.
--defaults-groupDefines the option group to read in the option file.
In situations where you find yourself using certain mariadb-backup options consistently every time you call it, you can set the options in an option file. The --defaults-group option defines what option group mariadb-backup reads for its options.
Options you define from the command-line can be set in the configuration file using minor formatting changes. For instance, if you find yourself perform compression operations frequently, you might set --compress-threads and --compress-chunk-size options in this way:
Now whenever you run a backup with the --compress option, it always performs the compression using 12 threads and 64K chunks.
See and for a list of the option groups read by mariadb-backup by default.
--encrypted-backupWhen this option is used with --backup, if mariadb-backup encounters a page that has a non-zero key_version value, then mariadb-backup assumes that the page is encrypted.
Use --skip-encrypted-backup instead to allow mariadb-backup to copy unencrypted tables that were originally created before MySQL 5.1.48.
--exportIf this option is provided during the --prepare stage, then it tells mariadb-backup to create .cfg files for each InnoDB file-per-table tablespace. These .cfg files are used to import transportable tablespaces in the process of restoring partial backups and restoring individual tables and partitions.
The --export option could require rolling back incomplete transactions that had modified the table. This will likely create a "new branch of history" that does not correspond to the server that had been backed up, which makes it impossible to apply another incremental backup on top of such additional changes. The option should only be applied when doing a --prepare of the last incremental.
mariadb-backup did not support the --export option. See about that. In earlier versions of MariaDB, this means that mariadb-backup could not create .cfg files for InnoDB file-per-table tablespaces during the --prepare stage. You can still import file-per-table tablespaces without the .cfg files in many cases, so it may still be possible in those versions to restore partial backups or to restore individual tables and partitions with just the .ibd files. If you have a full backup and you need to create .cfg files for InnoDB file-per-table tablespaces, then you can do so by preparing the backup as usual without the --export option, and then restoring the backup, and then starting the server. At that point, you can use the server's built-in features to copy the transportable tablespaces.
--extra-lsndirSaves an extra copy of the xtrabackup_checkpoints and xtrabackup_info files into the given directory.
When using the --backup option, mariadb-backup produces a number of backup files in the target directory. Using this option, you can have mariadb-backup produce additional copies of the xtrabackup_checkpoints and xtrabackup_info files in the given directory.
This is especially useful when using --stream for streaming output, e.g. for compression and/or encryption using external tools in combination with incremental backups, as the xtrabackup_checkpoints file necessary to determine the LSN to continue the incremental backup from is still accessible without uncompressing / decrypting the backup file first. Pass in the --extra-lsndir of the previous backup as --incremental-basedir .
--force-non-empty-directoriesAllows --copy-back or --move-back options to use non-empty target directories.
When using mariadb-backup with the --copy-back or --move-back options, they normally require a non-empty target directory to avoid conflicts. Using this option with either of command allows mariadb-backup to use a non-empty directory.
Bear in mind that this option does not enable overwrites. When copying or moving files into the target directory, if mariadb-backup finds that the target file already exists, it fails with an error.
--ftwrl-wait-query-typeDefines the type of query allowed to complete before mariadb-backup issues the global lock.
The --ftwrl-wait-query-type option supports the following query types. The default value is ALL.
When mariadb-backup runs, it issues a global lock to prevent data from changing during the backup process. When it encounters a statement in the process of executing, it waits until the statement is finished before issuing the global lock. Using this option, you can modify this default behavior to ensure that it waits only for certain query types, such as for SELECT and UPDATE statements.
--ftwrl-wait-thresholdDefines the minimum threshold for identifying long-running queries for FTWRL.
When mariadb-backup runs, it issues a global lock to prevent data from changing during the backup process and ensure a consistent record. If it encounters statements still in the process of executing, it waits until they complete before setting the lock. Using this option, you can set the threshold at which mariadb-backup engages FTWRL. When it --ftwrl-wait-timeout is not 0 and a statement has run for at least the amount of time given this argument, mariadb-backup waits until the statement completes or until the --ftwrl-wait-timeout expires before setting the global lock and starting the backup.
--ftwrl-wait-timeoutDefines the timeout to wait for queries before trying to acquire the global lock. The global lock refers to BACKUP STAGE BLOCK_COMMIT. The global lock refers to FLUSH TABLES WITH READ LOCK (FTWRL).
When mariadb-backup runs, it acquires a global lock to prevent data from changing during the backup process and ensure a consistent record. If it encounters statements still in the process of executing, it can be configured to wait until the statements complete before trying to acquire the global lock.
If the --ftwrl-wait-timeout is set to 0, mariadb-backup tries to acquire the global lock immediately without waiting. This is the default value.
If the --ftwrl-wait-timeout is set to a non-zero value, then mariadb-backup waits for the configured number of seconds until trying to acquire the global lock.
mariadb-backup exits if it can't acquire the global lock after waiting for the configured number of seconds.
The --ftwrl-wait-timeout option specifies the maximum time that mariadb-backup will wait to obtain the global lock required to begin a consistent backup.
this lock is acquired with BACKUP STAGE BLOCK_COMMIT.
this lock is acquired with FLUSH TABLES WITH READ LOCK (FTWRL).
If the lock cannot be obtained within the configured timeout, the backup process fails.
This option helps avoid failures caused by long-running MariaDB queries that block backup locks.
Example Errors
When the timeout is not set appropriately, backups may fail with messages such as:
or
Example log excerpt:
Originally, mariadb-backup could wait indefinitely for the lock. Starting with the fix for MDEV-20230:
The --ftwrl-wait-timeout option also ensures mariadb backup exits gracefully if the lock cannot be obtained within the timeout period.
This prevents backups from hanging when lock acquisition is blocked by long-running queries.
When to Use
Use --ftwrl-wait-timeout when:
Your workload includes long-running queries (for example, ALTER TABLE or large INSERT batches).
Backups sometimes fail with lock wait timeout errors.
You want mariadb-backup to either wait longer for the lock or exit cleanly if it cannot be obtained.
--galera-infoDefines whether you want to back up information about a Galera Cluster node's state.
When this option is used, mariadb-backup creates an additional file called xtrabackup_galera_info, which records information about a Galera Cluster node's state. It records the values of the and status variables.
You should only use this option when backing up a Galera Cluster node. If the server is not a Galera Cluster node, then this option has no effect.
This option, when enabled and used with GTID replication, will rotate the binary logs at backup time.
--historyDefines whether you want to track backup history in the mysql.mariadb_backup_history table.
When using this option, mariadb-backup records its operation in a table on the MariaDB Server. Passing a name to this option allows you group backups under arbitrary terms for later processing and analysis.
Information is written to mysql.mariadb_backup_history.
mariadb-backup also records this in the file.
Defines whether you want to track backup history in the PERCONA_SCHEMA.xtrabackup_history table.
When using this option, mariadb-backup
-H, --hostDefines the hostname for the MariaDB Server you want to backup.
Using this option, you can define the hostname or IP address to use when connecting to a local MariaDB Server over TCP/IP. By default, mariadb-backup attempts to connect to localhost.
Warning: No Remote Backups. This option does not allow you to back up a remote server. mariabackup must be run on the same server where the database files reside. The --host option is used only to establish the client connection for managing locks and retrieving metadata. The actual data files are always read from the local filesystem. Attempting to use this option to back up a remote host will result in a backup of the local machine's data, associated with the remote machine's binary log coordinates.
--includeThis option is a regular expression to be matched against table names in databasename.tablename format. It is equivalent to the --tables option. This is only valid in innobackupex mode, which can be enabled with the --innobackupex option.
--incrementalDefines whether you want to take an increment backup, based on another backup. This is only valid in innobackupex mode, which can be enabled with the --innobackupex option.
Using this option with the --backup option makes the operation incremental rather than a complete overwrite. When this option is specified, either the --incremental-lsn or --incremental-basedir options can also be given. If neither option is given, --incremental-basedir is used by default, set to the first timestamped backup directory in the backup base directory.
If a backup is a incremental backup, then mariadb-backup records that detail in the xtrabackup_info file.
--incremental-basedirDefines whether you want to take an incremental backup, based on another backup.
Using this option with the --backup option makes the operation incremental rather than a complete overwrite. mariadb-backup only copies pages from .ibd files if they are newer than the backup in the specified directory.
If a backup is a incremental backup, then mariadb-backup records that detail in the xtrabackup_info file.
--incremental-dirDefines whether you want to take an incremental backup, based on another backup.
Using this option with --prepare command option makes the operation incremental rather than a complete overwrite. mariadb-backup will apply .delta files and log files into the target directory.
If a backup is a incremental backup, then mariadb-backup records that detail in the xtrabackup_info file.
--incremental-force-scanDefines whether you want to force a full scan for incremental backups.
When using mariadb-backup to perform an incremental backup, this option forces it to also perform a full scan of the data pages being backed up, even when there's bitmap data on the changes. MariaDB does not support changed page bitmaps, so this option is useless in those versions. See for more information.
--incremental-history-nameDefines a logical name for the backup.
mariadb-backup can store data about its operations on the MariaDB Server. Using this option, you can define the logical name it uses in identifying the backup.
The table it uses by default is named mysql.mariadb_backup_history. Prior to , the default table was PERCONA_SCHEMA.xtrabackup_history.
mariadb-backup also records this in the xtrabackup_info file.
--incremental-history-uuidDefines a UUID for the backup.
mariadb-backup can store data about its operations on the MariaDB Server. Using this option, you can define the UUID it uses in identifying a previous backup to increment from. It checks --incremental-history-name, --incremental-basedir, and --incremental-lsn. If mariadb-backup fails to find a valid lsn, it generates an error.
The table it uses is named PERCONA_SCHEMA.xtrabackup_history, but expect that name to change in future releases. See for more information.
Table Name and Schema Changes (MariaDB 10.11):
MariaDB 10.11 and later: Uses mysql.mariadb_backup_history (InnoDB).
MariaDB 10.10 and earlier: Uses PERCONA_SCHEMA.xtrabackup_history (CSV).
mariadb-backup also records this in the xtrabackup_info file.
--incremental-lsnDefines the sequence number for incremental backups.
Using this option, you can define the sequence number (LSN) value for --backup operations. During backups, mariadb-backup only copies .ibd pages newer than the specified values.
Incorrect LSN values can make the backup unusable. It is impossible to diagnose this issue.
--innobackupexUse to enable innobackupex mode, which is a compatibility mode.
--innodbThis option has no effect. Set only for MySQL option compatibility.
--innodb-adaptive-hash-indexEnables InnoDB Adaptive Hash Index.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option you can explicitly enable the InnoDB Adaptive Hash Index. This feature is enabled by default for mariadb-backup. If you want to disable it, use --skip-innodb-adaptive-hash-index.
--innodb-autoextend-incrementDefines the increment in megabytes for auto-extending the size of tablespace file.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can set the increment in megabytes for automatically extending the size of tablespace data file in InnoDB.
--innodb-buffer-pool-filenameUsing this option has no effect. It is available to provide compatibility with the MariaDB Server.
--innodb-buffer-pool-sizeDefines the memory buffer size InnoDB uses the cache data and indexes of the table.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can configure the buffer pool for InnoDB operations.
--innodb-checksum-algorithminnodb_checksum_algorithm has been removed.
--innodb-data-file-pathDefines the path to individual data files.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option you can define the path to InnoDB data files. Each path is appended to the --innodb-data-home-dir option.
--innodb-data-home-dirDefines the home directory for InnoDB data files.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option you can define the path to the directory containing InnoDB data files. You can specific the files using the --innodb-data-file-path option.
--innodb-doublewriteEnables doublewrites for InnoDB tables.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. When using this option, mariadb-backup improves fault tolerance on InnoDB tables with a doublewrite buffer. By default, this feature is enabled. Use this option to explicitly enable it. To disable doublewrites, use the --skip-innodb-doublewrite option.
--innodb-encrypt-logDefines whether you want to encrypt InnoDB logs.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can tell mariadb-backup that you want to encrypt logs from its InnoDB activity.
--innodb-file-io-threadsDefines the number of file I/O threads in InnoDB.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can define the number of file I/O threads mariadb-backup uses on InnoDB tables.
--innodb-file-per-tableDefines whether you want to store each InnoDB table as an .ibd file.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option causes mariadb-backup to store each InnoDB table as an .ibd file in the target directory.
--innodb-flush-methodDefines the data flush method. Ignored from .
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can define the data flush method mariadb-backup uses with InnoDB tables.
--innodb-io-capacityDefines the number of IOP's the utility can perform.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can limit the I/O activity for InnoDB background tasks. It should be set around the number of I/O operations per second that the system can handle, based on drive or drives being used.
--innodb-log-buffer-sizeThe size of the buffer that will be used for reading log during mariadb-backup --prepare. Ignored when using --innodb-log-file-mmap.
--innodb-log-checksumsDefines whether to include checksums in the InnoDB logs.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can explicitly set mariadb-backup to include checksums in the InnoDB logs. The feature is enabled by default. To disable it, use the --skip-innodb-log-checksums option.
--innodb-log-checkpoint-nowAt the start of a backup, instruct the server to write out all modified pages to the data files, to minimize the size of the ib_logfile0 that needs to be copied.
--innodb-log-file-mmapMariaDB starting with 10.11.10, 11.4.4: When this option is enabled, mariadb-backup will read the ib_logfile0 via a memory mapping, rather than by reading into a separately allocated buffer of --innodb-log-buffer-size.
--innodb-log-files-in-groupThis option has no functionality in mariadb-backup. It exists for MariaDB Server compatibility.
--innodb-log-group-home-dirDefines the path to InnoDB log files.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can define the path to InnoDB log files.
--innodb-max-dirty-pages-pctDefines the percentage of dirty pages allowed in the InnoDB buffer pool.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can define the maximum percentage of dirty, (that is, unwritten) pages that mariadb-backup allows in the InnoDB buffer pool.
--innodb-open-filesDefines the number of files kept open at a time.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can set the maximum number of files InnoDB keeps open at a given time during backups.
--innodb-page-sizeDefines the universal page size.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can define the universal page size in bytes for mariadb-backup.
--innodb-read-io-threadsDefines the number of background read I/O threads in InnoDB.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can set the number of I/O threads MariaDB uses when reading from InnoDB.
--innodb-undo-directoryDefines the directory for the undo tablespace files.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can define the path to the directory where you want MariaDB to store the undo tablespace on InnoDB tables. The path can be absolute.
--innodb-undo-tablespacesDefines the number of undo tablespaces to use.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can define the number of undo tablespaces you want to use during the backup.
--innodb-use-native-aioDefines whether you want to use native AI/O.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can enable the use of the native asynchronous I/O subsystem. It is only available on Linux operating systems.
--innodb-write-io-threadsDefines the number of background write I/O threads in InnoDB.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can set the number of background write I/O threads mariadb-backup uses.
--kill-long-queries-timeoutDefines the timeout for blocking queries.
When mariadb-backup runs, it issues a FLUSH TABLES WITH READ LOCK statement. It then identifies blocking queries. Using this option you can set a timeout in seconds for these blocking queries. When the time runs out, mariadb-backup kills the queries.
The default value is 0, which causes mariadb-backup to not attempt killing any queries.
--kill-long-query-typeDefines the query type the utility can kill to unblock the global lock.
When mariadb-backup encounters a query that sets a global lock, it can kill the query in order to free up MariaDB Server for the backup. Using this option, you can choose the types of query it kills: SELECT, UPDATE, or both set with ALL. The default is ALL.
--lock-ddl-per-tablePrevents DDL for each table to be backed up by acquiring MDL lock on that.
--logThis option has no functionality. It is set to ensure compatibility with MySQL.
--log-binDefines the base name for the log sequence.
Using this option you, you can set the base name for mariadb-backup to use in log sequences.
--log-copy-intervalDefines the copy interval between checks done by the log copying thread.
Using this option, you can define the copy interval mariadb-backup uses between checks done by the log copying thread. The given value is in milliseconds.
--log-innodb-page-corruptionContinue backup if InnoDB corrupted pages are found. The pages are logged in innodb_corrupted_pages and backup is finished with error. --prepare will try to fix corrupted pages. If innodb_corrupted_pages exists after --prepare in base backup directory, backup still contains corrupted pages and can not be considered as consistent.
--move-backRestores the backup to the data directory.
Using this command, mariadb-backup moves the backup from the target directory to the data directory, as defined by the --datadir option. You must stop the MariaDB Server before running this command. The data directory must be empty. If you want to overwrite the data directory with the backup, use the --force-non-empty-directories option.
Bear in mind, before you can restore a backup, you first need to run mariadb-backup with the --prepare option. In the case of full backups, this makes the files point-in-time consistent. With incremental backups, this applies the deltas to the base backup. Once the backup is prepared, you can run --move-back to apply it to MariaDB Server.
Running the --move-back command moves the backup files to the data directory. Use this command if you don't want to save the backup for later. If you do want to save the backup for later, use the --copy-back option.
--mysqldUsed internally to prepare a backup.
--no-backup-locksmariadb-backup locks the database by default when it runs. This option disables support for Percona Server's backup locks.
When backing up Percona Server, mariadb-backup would use backup locks by default. To be specific, backup locks refers to the LOCK TABLES FOR BACKUP and LOCK BINLOG FOR BACKUP statements. This option can be used to disable support for Percona Server's backup locks. This option has no effect when the server does not support Percona's backup locks.
Deprecated and has no effect from , , and as MariaDB now always uses backup locks for better performance. See .
--no-lockDisables table locks with the FLUSH TABLE WITH READ LOCK statement.
Using this option causes mariadb-backup to disable table locks with the FLUSH TABLE WITH READ LOCK statement. Only use this option if:
You are not executing DML statements on non-InnoDB tables during the backup. This includes the mysql database system tables (which are MyISAM).
You are not executing any DDL statements during the backup.
You are not using the file xtrabackup_binlog_info, which is not consistent with the data when --no-lock is used. Use the file xtrabackup_binlog_pos_innodb
If you're considering --no-lock due to backups failing to acquire locks, this may be due to incoming replication events preventing the lock. Consider using the --safe-slave-backup option to momentarily stop the replica thread. This alternative may help the backup to succeed without resorting to --no-lock.
The --no-lock option only provides a consistent backup if the user ensures that no DDL or non-transactional table updates occur during the backup. The --no-lock option is not supported by MariaDB plc.
--no-timestampThis option prevents creation of a time-stamped subdirectory of the BACKUP-ROOT-DIR given on the command line. When it is specified, the backup is done in BACKUP-ROOT-DIR instead. This is only valid in innobackupex mode, which can be enabled with the --innobackupex option.
--no-version-checkDisables version check.
Using this option, you can disable mariadb-backup version check.
--open-files-limitDefines the maximum number of file descriptors.
Using this option, you can define the maximum number of file descriptors mariadb-backup reserves with setrlimit().
--parallelDefines the number of threads to use for parallel data file transfer.
Using this option, you can set the number of threads mariadb-backup uses for parallel data file transfers. By default, it is set to 1.
-p, --passwordDefines the password to use to connect to MariaDB Server.
When you run mariadb-backup, it connects to MariaDB Server in order to access and back up the databases and tables. Using this option, you can set the password mariadb-backup uses to access the server. To set the user, use the --user option.
--plugin-dirDefines the directory for server plugins.
Using this option, you can define the path mariadb-backup reads for MariaDB Server plugins. It only uses it during the --prepare phase to load the encryption plugin. It defaults to the plugin_dir server system variable.
--plugin-loadThe option has been removed.
-P, --portDefines the server port to connect to.
When you run mariadb-backup, it connects to MariaDB Server in order to access and back up your databases and tables. Using this option, you can set the port the utility uses to access the server over TCP/IP. To set the host, see the --host option. Use mysql --help for more details.
--preparePrepares an existing backup to restore to the MariaDB Server.
Files that mariadb-backup generates during --backup operations in the target directory are not ready for use on the Server. Before you can restore the data to MariaDB, you first need to prepare the backup.
In the case of full backups, the files are not point in time consistent, since they were taken at different times. If you try to restore the database without first preparing the data, InnoDB rejects the new data as corrupt. Running mariadb-backup with the --prepare command readies the data so you can restore it to MariaDB Server. When working with incremental backups, you need to use the --prepare command and the --incremental-dir option to update the base backup with the deltas from an incremental backup.
Once the backup is ready, you can use the --copy-back or the --move-back options to restore the backup to the server.
--print-defaultsPrints the utility argument list, then exits.
Using this argument, MariaDB prints the argument list to stdout and then exits. You may find this useful in debugging to see how the options are set for the utility.
--print-paramPrints the MariaDB Server options needed for copy-back.
Using this option, mariadb-backup prints to stdout the MariaDB Server options that the utility requires to run the --copy-back command option.
--rollback-xaBy default, mariadb-backup will not commit or rollback uncommitted XA transactions, and when the backup is restored, any uncommitted XA transactions must be manually committed using XA COMMIT or manually rolled back using XA ROLLBACK.
MariaDB starting with
mariadb-backup's --rollback-xa option is not present because the server has more robust ways of handling uncommitted XA transactions.
This is an experimental option. Do not use this option in older versions. Older implementation can cause corruption of InnoDB data.
--rsyncDefines whether to use rsync.
During normal operation, mariadb-backup transfers local non-InnoDB files using a separate call to cp for each file. Using this option, you can optimize this process by performing this transfer with rsync, instead.
This option is not compatible with the --stream option.
Deprecated and has no effect from , , and as rsync will not work on tables that are in use. See .
--safe-slave-backupStops replica SQL threads for backups.
When running mariadb-backup on a server that uses replication, you may occasionally encounter locks that block backups. Using this option, it stops replica SQL threads and waits until the Slave_open_temp_tables in the SHOW STATUS statement is zero. If there are no open temporary tables, the backup runs, otherwise the SQL thread starts and stops until there are no open temporary tables.
The backup fails if the Slave_open_temp_tables doesn't reach zero after the timeout period set by the --safe-slave-backup-timeout option.
--safe-slave-backup-timeoutDefines the timeout for replica backups.
When running mariadb-backup on a server that uses replication, you may occasionally encounter locks that block backups. With the --safe-slave-backup option, it waits until the Slave_open_temp_tables in the SHOW STATUS statement reaches zero. Using this option, you set how long it waits. It defaults to 300.
--secure-authRefuses client connections to servers using the older protocol.
Using this option, you can set it explicitly to refuse client connections to the server when using the older protocol, from before 4.1.1. This feature is enabled by default. Use the --skip-secure-auth option to disable it.
--skip-innodb-adaptive-hash-indexDisables InnoDB Adaptive Hash Index.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option you can explicitly disable the InnoDB Adaptive Hash Index. This feature is enabled by default for mariadb-backup. If you want to explicitly enable it, use --innodb-adaptive-hash-index.
--skip-innodb-doublewriteDisables doublewrites for InnoDB tables.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. When doublewrites are enabled, InnoDB improves fault tolerance with a doublewrite buffer. By default this feature is turned on. Using this option you can disable it for mariadb-backup. To explicitly enable doublewrites, use the --innodb-doublewrite option.
--skip-innodb-log-checksumsDefines whether to exclude checksums in the InnoDB logs.
mariadb-backup initializes its own embedded instance of InnoDB using the same configuration as defined in the configuration file. Using this option, you can set mariadb-backup to exclude checksums in the InnoDB logs. The feature is enabled by default. To explicitly enable it, use the --innodb-log-checksums option.
--skip-secure-authRefuses client connections to servers using the older protocol.
Using this option, you can set it accept client connections to the server when using the older protocol, from before 4.1.1. By default, it refuses these connections. Use the --secure-auth option to explicitly enable it.
--slave-infoPrints the binary log position and the name of the primary server.
If the server is a replica, then this option causes mariadb-backup to print the hostname of the replica's replication primary and the binary log file and position of the replica's SQL thread to stdout.
This option also causes mariadb-backup to record this information as a CHANGE MASTER statement that can be used to set up a new server as a replica of the original server's primary after the backup has been restored. This information are written to the xtrabackup_slave_info file.
mariadb-backup does not check if GTIDs are being used in replication. It takes a shortcut and assumes that if the gtid_slave_pos system variable is non-empty, then it writes the CHANGE MASTER statement with the MASTER_USE_GTID option set to slave_pos. Otherwise, it writes the CHANGE MASTER statement with the MASTER_LOG_FILE and MASTER_LOG_POS options using the primary's binary log file and position. See for more information.
-S, --socketDefines the socket for connecting to local database.
Using this option, you can define the UNIX domain socket you want to use when connecting to a local database server. The option accepts a string argument. For more information, see the mysql --help command.
--sslEnables TLS. By using this option, you can explicitly configure mariadb-backup to encrypt its connection with TLS when communicating with the server. You may find this useful when performing backups in environments where security is extra important or when operating over an insecure network.
TLS is also enabled even without setting this option when certain other TLS options are set. For example, see the descriptions of the following options:
--ssl-ca
--ssl-capath
--ssl-cert
--ssl-cipher
--ssl-caDefines a path to a PEM file that should contain one or more X509 certificates for trusted Certificate Authorities (CAs) to use for TLS. This option requires that you use the absolute path, not a relative path. For example:
This option is usually used with other TLS options. For example:
See Secure Connections Overview: Certificate Authorities (CAs) for more information.
This option implies the --ssl option.
--ssl-capathDefines a path to a directory that contains one or more PEM files that should each contain one X509 certificate for a trusted Certificate Authority (CA) to use for TLS. This option requires that you use the absolute path, not a relative path. For example:
This option is usually used with other TLS options. For example:
The directory specified by this option needs to be run through the command.
See Secure Connections Overview: Certificate Authorities (CAs) for more information
This option implies the --ssl option.
--ssl-certDefines a path to the X509 certificate file to use for TLS. This option requires that you use the absolute path, not a relative path. For example:
This option is usually used with other TLS options. For example:
This option implies the --ssl option.
--ssl-cipherDefines the list of permitted ciphers or cipher suites to use for TLS. For example:
This option is usually used with other TLS options. For example:
To determine if the server restricts clients to specific ciphers, check the ssl_cipher system variable.
This option implies the --ssl option.
--ssl-crlDefines a path to a PEM file that should contain one or more revoked X509 certificates to use for TLS. This option requires that you use the absolute path, not a relative path. For example:
This option is usually used with other TLS options. For example:
See Secure Connections Overview: Certificate Revocation Lists (CRLs) for more information.
This option is only supported if mariadb-backup was built with OpenSSL. If mariadb-backup was built with yaSSL, then this option is not supported. See TLS and Cryptography Libraries Used by MariaDB for more information about which libraries are used on which platforms.
--ssl-crlpathDefines a path to a directory that contains one or more PEM files that should each contain one revoked X509 certificate to use for TLS. This option requires that you use the absolute path, not a relative path. For example:
This option is usually used with other TLS options. For example:
The directory specified by this option needs to be run through the command.
See Secure Connections Overview: Certificate Revocation Lists (CRLs) for more information.
This option is only supported if mariadb-backup was built with OpenSSL. If mariadb-backup was built with yaSSL, then this option is not supported. See TLS and Cryptography Libraries Used by MariaDB for more information about which libraries are used on which platforms.
--ssl-keyDefines a path to a private key file to use for TLS. This option requires that you use the absolute path, not a relative path. For example:
This option is usually used with other TLS options. For example:
This option implies the --ssl option.
--ssl-verify-server-certEnables server certificate verification. This option is disabled by default.
This option is usually used with other TLS options. For example:
--streamStreams backup files to stdout.
Using this command option, you can set mariadb-backup to stream the backup files to stdout in the given format. Currently, the supported format is xbstream.
To extract all files from the xbstream archive into a directory use the mbstream utility
If a backup is streamed, then mariadb-backup records the format in the xtrabackup_info file.
--tablesDefines the tables you want to include in the backup.
Using this option, you can define what tables you want mariadb-backup to back up from the database. The table values are defined using Regular Expressions (regex). To define the tables you want to exclude from the backup, see the --tables-exclude option.
In the example, nodes_* matches tables named nodes, nodes_, nodes__, and so forth, because * means zero or more occurrences of the previous character (_).
If instead you want to back up all tables whose names start with nodes, the regular expression is ^nodes., and to exclude tables starting with nodes_tmp, the expression is ^nodes_tmp.. (Notice the trailing period (.); it means zero or more occurrences of characters following nodes.) The command looks like this:
In that example, some of the tables included via the --tables option are excluded by --tables-excludes. That works because --tables-exclude takes precedence over --tables.
You can specify multiple table name regex patterns as a comma-separated list, for both the --tables and the --tables-exclude options.
The following command backs up all tables in the test1 and test2 databases, except the exclude_table table in the test2 database, and stores the backup files under /path/to/backups/:
The and options, if used, take precedence over --tables and --tables-exclude. That is, they can filter out tables, which are then not "visible" to the latter mentioned options.
If a backup is a partial backup, mariadb-backup records that detail in the xtrabackup_info file.
--tables-excludeDefines the tables you want to exclude from the backup.
Using this option, you can define what tables you want mariadb-backup to exclude from the backup. The table values are defined using Regular Expressions. To define the tables you want to include from the backup, see the --tables option.
If a backup is a partial backup, mariadb-backup records that detail in the xtrabackup_info file.
--tables-fileDefines path to file with tables for backups.
Using this option, you can set a path to a file listing the tables you want to back up. mariadb-backup iterates over each line in the file. The format is database.table.
If a backup is a partial backup, then mariadb-backup will record that detail in the xtrabackup_info file.
--target-dirDefines the destination directory.
Using this option you can define the destination directory for the backup. mariadb-backup writes all backup files to this directory. mariadb-backup will create the directory, if it does not exist (but it does not create the full path recursively, i.e. at least parent directory if the --target-dir must exist.
--throttleDefines the limit for I/O operations per second in IOS values.
Using this option, you can set a limit on the I/O operations mariadb-backup performs per second in IOS values. It is only used during the --backup option.
--tls-versionThis option accepts a comma-separated list of TLS protocol versions. A TLS protocol version is only enabled if it is present in this list. All other TLS protocol versions will not be permitted. For example:
This option is usually used with other TLS options. For example:
See Secure Connections Overview: TLS Protocol Versions for more information.
-t, --tmpdirDefines path for temporary files.
Using this option, you can define the path to a directory mariadb-backup uses in writing temporary files. If you want to use more than one, separate the values by a semicolon (that is, ;). When passing multiple temporary directories, it cycles through them using round-robin.
--use-memoryDefines the buffer pool size that is used during the prepare stage.
Using this option, you can define the buffer pool size for mariadb-backup. Use it instead of buffer_pool_size.
--userDefines the username for connecting to the MariaDB Server.
When mariadb-backup runs, it connects to the specified MariaDB Server to get its backups. Using this option, you can define the database user used for authentication. Starting from , , , , , , , if the --user option is omitted, the user name is detected from the OS.
--verboseDisplays verbose output.
--versionPrints the mariadb-backup version information to stdout.
This page is licensed: CC BY-SA / Gnu FDL
Information is written to PERCONA_SCHEMA.xtrabackup_history.
mariadb-backup also records this in the xtrabackup_info file.
All tables you're backing up use the InnoDB storage engine.
OFF
Disables the retrieval of binary log information
ON
Enables the retrieval of binary log information, performs locking where available to ensure consistency
LOCKLESS
Unsupported option
AUTO
Enables the retrieval of binary log information using ON or LOCKLESS where supported
quicklz
Uses the QuickLZ compression algorithm
ALL
Waits until all queries complete before issuing the global lock
SELECT
Waits until SELECT statements complete before issuing the global lock
UPDATE
Waits until UPDATE statements complete before issuing the global lock
mariadb-backup --innobackupex --apply-logmariadb-backup --backup
--target-dir /path/to/backup \
--user user_name --password user_passwd--binlog-info[=OFF | ON | LOCKLESS | AUTO]mariadb-backup --binlog-info --backupmariadb-backup --close-files --prepare--compress[=compression_algorithm]mariadb-backup --compress --backup--compress-chunk-size=#mariadb-backup --backup --compress \
--compress-threads=12 --compress-chunk-size=5M--compress-threads=#mariadb-backup --compress --compress-threads=12 --backupmariadb-backup --copy-back --force-non-empty-directoriesmariadb-backup --core-file --backup--databases="database[.table][ database[.table] ...]"mariadb-backup --backup \
--databases="example.table1 example.table2"--databases-exclude="database[.table][ database[.table] ...]"mariadb-backup --backup \
--databases="example" \
--databases-exclude="example.table1 example.table2"--databases-file="/path/to/database-file"database[.table]cat main-backupexample1
example2.table1
example2.table2mariadb-backup --backup --databases-file=main-backup--datadir=PATHmariadb-backup --backup -h /var/lib64/mysqlmariadb-backup --compress --backupmariadb-backup --decompress--defaults-extra-file=/path/to/configmariadb-backup --backup \
--defaults-file-extra=addition-config.cnf \
--defaults-file=config.cnf--defaults-file=/path/to/configmariadb-backup --backup \
--defaults-file=config.cnf--defaults-group="name"[mariadb-backup]
compress_threads = 12
compress_chunk_size = 64Kmariadb-backup --compress --backupmariadb-backup --prepare --export--extra-lsndir=PATHmariadb-backup --extra-lsndir=extras/ --backupmariadb-backup --force-non-empty-directories --copy-back--ftwrl-wait-query-type=[ALL | UPDATE | SELECT]mariadb-backup --backup \
--ftwrl-wait-query-type=UPDATE--ftwrl-wait-threshold=#mariadb-backup --backup \
--ftwrl-wait-timeout=90 \
--ftwrl-wait-threshold=30--ftwrl-wait-timeout=#mariadb-backup --backup \
--ftwrl-wait-query-type=UPDATE \
--ftwrl-wait-timeout=5Unable to obtain lock. Please try again later.FATAL ERROR: failed to execute query BACKUP STAGE START:
Lock wait timeout exceeded; try restarting transaction[00] 2022-02-08 15:43:25 Unable to obtain lock. Please try again later.
[00] 2022-02-08 15:43:25 Error on BACKUP STAGE START query execution
mariabackup: Stopping log copying thread.mariadb-backup --backup --galera-info--history[=name]mariadb-backup --backup --history=backup_all--history[=name]--host=namemariadb-backup --backup \
--host="example.com"mariadb-backup --innobackupex --incrementalmariadb-backup --innobackupex --backup --incremental \
--incremental-basedir=/data/backups \
--target-dir=/data/backups--incremental-basedir=PATHmariadb-backup --backup \
--incremental-basedir=/data/backups \
--target-dir=/data/backups--increment-dir=PATHmariadb-backup --prepare \
--increment-dir=backups/mariadb-backup --backup \
--incremental-basedir=/path/to/target \
--incremental-force-scan--incremental-history-name=namemariadb-backup --backup \
--incremental-history-name=morning_backup--incremental-history-uuid=namemariadb-backup --backup \
--incremental-history-uuid=main-backup012345678--incremental-lsn=namemariadb-backup --innobackupexmariadb-backup --backup \
--innodb-adaptive-hash-index--innodb-autoextend-increment=36mariadb-backup --backup \
--innodb-autoextend-increment=35--innodb-buffer-pool-size=124Mmariadb-backup --backup \
--innodb-buffer-pool-size=124M--innodb-data-file-path=/path/to/filemariadb-backup --backup \
--innodb-data-file-path=ibdata1:13M:autoextend \
--innodb-data-home-dir=/var/dbs/mysql/data--innodb-data-home-dir=PATHmariadb-backup --backup \
--innodb-data-file-path=ibdata1:13M:autoextend \
--innodb-data-home-dir=/var/dbs/mysql/datamariadb-backup --backup \
--innodb-doublewrite--innodb-file-io-threads=#mariadb-backup --backup \
--innodb-file-io-threads=5--innodb-flush-method=fdatasync
| O_DSYNC
| O_DIRECT
| O_DIRECT_NO_FSYNC
| ALL_O_DIRECTmariadb-backup --backup \
--innodb-flush-method==_DIRECT_NO_FSYNC--innodb-io-capacity=#mariadb-backup --backup \
--innodb-io-capacity=200mariadb-backup --backup \
--innodb-log-checksumsmariadb-backup --backup \
--innodb-log-checkpoint-now--innodb-log-group-home-dir=PATHmariadb-backup --backup \
--innodb-log-group-home-dir=/path/to/logs--innodb-max-dirty-pages-pct=#mariadb-backup --backup \
--innodb-max-dirty-pages-pct=80--innodb-open-files=#mariadb-backup --backup \
--innodb-open-files=10--innodb-page-size=#mariadb-backup --backup \
--innodb-page-size=16k--innodb-read-io-threads=#mariadb-backup --backup \
--innodb-read-io-threads=4--innodb-undo-directory=PATHmariadb-backup --backup \
--innodb-undo-directory=/path/to/innodb_undo--innodb-undo-tablespaces=#mariadb-backup --backup \
--innodb-undo-tablespaces=10mariadb-backup --backup \
--innodb-use-native-aio--innodb-write-io-threads=#mariadb-backup --backup \
--innodb-write-io-threads=4--kill-long-queries-timeout=#mariadb-backup --backup \
--kill-long-queries-timeout=10--kill-long-query-type=ALL | UPDATE | SELECTmariadb-backup --backup \
--kill-long-query-type=UPDATE--log-bin[=name]--log-copy-interval=#mariadb-backup --backup \
--log-copy-interval=50mariadb-backup --move-back \
--datadir=/var/mysqlmariadb-backup --backup --no-backup-locksmariadb-backup --backup --no-lockmariadb-backup --backup --no-version-check--open-files-limit=#mariadb-backup --backup \
--open-files-limit=--parallel=#--password=passwdmariadb-backup --backup \
--user=root \
--password=root_password--plugin-dir=PATHmariadb-backup --backup \
--plugin-dir=/var/mysql/lib/plugin--port=#mariadb-backup --backup \
--host=192.168.11.1 \
--port=3306mariadb-backup --preparemariadb-backup --print-defaultsmariadb-backup --print-parammariadb-backup --backup --rsyncmariadb-backup --backup \
--safe-slave-backup \
--safe-slave-backup-timeout=500--safe-slave-backup-timeout=#mariadb-backup --backup \
--safe-slave-backup \
--safe-slave-backup-timeout=500mariadb-backup --backup --secure-authmariadb-backup --backup \
--skip-innodb-adaptive-hash-indexmariadb-backup --backup \
--skip-innodb-doublewritemariadb-backup --backup --skip-secure-authmariadb-backup --slave-info--socket=namemariadb-backup --backup \
--socket=/var/mysql/mysql.sock--ssl-ca=/etc/my.cnf.d/certificates/ca.pemmariadb-backup --backup \
--ssl-cert=/etc/my.cnf.d/certificates/client-cert.pem \
--ssl-key=/etc/my.cnf.d/certificates/client-key.pem \
--ssl-ca=/etc/my.cnf.d/certificates/ca.pem--ssl-capath=/etc/my.cnf.d/certificates/ca/mariadb-backup --backup \
--ssl-cert=/etc/my.cnf.d/certificates/client-cert.pem \
--ssl-key=/etc/my.cnf.d/certificates/client-key.pem \
--ssl-ca=/etc/my.cnf.d/certificates/ca.pem \
--ssl-capath=/etc/my.cnf.d/certificates/ca/--ssl-cert=/etc/my.cnf.d/certificates/client-cert.pemmariadb-backup --backup \
--ssl-cert=/etc/my.cnf.d/certificates/client-cert.pem \
--ssl-key=/etc/my.cnf.d/certificates/client-key.pem \
--ssl-ca=/etc/my.cnf.d/certificates/ca.pem--ssl-cipher=namemariadb-backup --backup \
--ssl-cert=/etc/my.cnf.d/certificates/client-cert.pem \
--ssl-key=/etc/my.cnf.d/certificates/client-key.pem \
--ssl-ca=/etc/my.cnf.d/certificates/ca.pem \
--ssl-cipher=TLSv1.2--ssl-crl=/etc/my.cnf.d/certificates/crl.pemmariadb-backup --backup \
--ssl-cert=/etc/my.cnf.d/certificates/client-cert.pem \
--ssl-key=/etc/my.cnf.d/certificates/client-key.pem \
--ssl-ca=/etc/my.cnf.d/certificates/ca.pem \
--ssl-crl=/etc/my.cnf.d/certificates/crl.pem--ssl-crlpath=/etc/my.cnf.d/certificates/crl/mariadb-backup --backup \
--ssl-cert=/etc/my.cnf.d/certificates/client-cert.pem \
--ssl-key=/etc/my.cnf.d/certificates/client-key.pem \
--ssl-ca=/etc/my.cnf.d/certificates/ca.pem \
--ssl-crlpath=/etc/my.cnf.d/certificates/crl/--ssl-key=/etc/my.cnf.d/certificates/client-key.pemmariadb-backup --backup \
--ssl-cert=/etc/my.cnf.d/certificates/client-cert.pem \
--ssl-key=/etc/my.cnf.d/certificates/client-key.pem \
--ssl-ca=/etc/my.cnf.d/certificates/ca.pemmariadb-backup --backup \
--ssl-cert=/etc/my.cnf.d/certificates/client-cert.pem \
--ssl-key=/etc/my.cnf.d/certificates/client-key.pem \
--ssl-ca=/etc/my.cnf.d/certificates/ca.pem \
--ssl-verify-server-cert--stream=xbstreammariadb-backup --stream=xbstream > backup.xbmbstream -x < backup.xb--tables=REGEXmariadb-backup --backup \
--databases=example \
--tables=nodes_* \
--tables-exclude=nodes_tmpmariadb-backup --backup \
--databases=example \
--tables=^nodes. \
--tables-exclude=^nodes_tmp.mariadb-backup --backup \
--tables=test1[.].*,test2[.].* \
--tables-exclude=^test2[.]exclude_table
--target-dir=/path/to/backups/--tables-exclude=REGEX--tables-file=/path/to/filemariadb-backup --backup \
--databases=example \
--tables-file=/etc/mysql/backup-file--target-dir=/path/to/targetmariadb-backup --backup \
--target-dir=/data/backups--throttle=#--tls-version="TLSv1.2,TLSv1.3"mariadb-backup --backup \
--ssl-cert=/etc/my.cnf.d/certificates/client-cert.pem \
--ssl-key=/etc/my.cnf.d/certificates/client-key.pem \
--ssl-ca=/etc/my.cnf.d/certificates/ca.pem \
--tls-version="TLSv1.2,TLSv1.3"--tmpdir=/path/tmp[;/path/tmp...]mariadb-backup --backup \
--tmpdir=/data/tmp;/tmp--use-memory=124Mmariadb-backup --prepare \
--use-memory=124M--user=name
-u namemariadb-backup --backup \
--user=root \
--password=root_passwdmariadb-backup --verbosemariadb-backup --versionmariadb-backup --backup --history=backup_allBack up specific databases or tables. This guide explains how to filter your backup to include only the data you need.
When using mariadb-backup, you have the option of performing partial backups. Partial backups allow you to choose which databases or tables to backup, as long as the table or partition involved is in an InnoDB file-per-table tablespace.This page documents how to perform partial backups.
Just like with full backups, in order to back up the database, you need to run mariadb-backup with the --backup option to tell it to perform a backup and with the --target-dir option to tell it where to place the backup files. The target directory must be empty or not exist.
For a partial backup, there are a few other arguments that you can provide as well:
To tell it which databases to backup, you can provide the --databases option.
To tell it which databases to exclude from the backup, you can provide the --databases-exclude option.
To tell it to check a file for the databases to backup, you can provide the --databases-file option.
The non-file partial backup options support regex in the database and table names.
For example, to take a backup of any database that starts with the string app1_ and any table in those databases that start with the string tab_, run the following command:
You can use the --history option with a partial backup to log the operation in the history table for auditing purposes.
You cannot use a partial backup as the base for an incremental backup history chain. The --incremental-history-name option is incompatible with partial backups because restoring partial incrementals requires specific preparation steps (--export) that the history feature does not automate.
The time the backup takes depends on the size of the databases or tables you're backing up. You can cancel the backup if you need to, as the backup process does not modify the database.
mariadb-backup writes the backup files to the target directory. If the target directory doesn't exist, then it creates it. If the target directory exists and contains files, then it raises an error and aborts.
Just like with full backups, the data files that mariadb-backup creates in the target directory are not point-in-time consistent, given that the data files are copied at different times during the backup operation. If you try to restore from these files, InnoDB notices the inconsistencies and crashes to protect you from corruption. In fact, for partial backups, the backup is not even a completely functional MariaDB data directory, so InnoDB would raise more errors than it would for full backups. This point will also be very important to keep in mind during the restore process.
Before you can restore from a backup, you first need to prepare it to make the data files consistent. You can do so with the --prepare command option.
Partial backups rely on InnoDB's transportable tablespaces. For MariaDB to import tablespaces like these, InnoDB looks for a file with a .cfg extension. For mariadb-backup to create these files, you also need to add the --export option during the prepare step.
For example, you might execute the following command:
If this operation completes without error, then the backup is ready to be restored.
mariadb-backup did not support the --export option. See about that. This means that mariadb-backup could not create .cfg files for InnoDB file-per-table tablespaces during the --prepare stage. You can still import file-per-table tablespaces without the .cfg files in many cases, so it may still be possible in those versions to restore partial backups or to restore individual tables and partitions with just the .ibd files. If you have a full backup and you need to create .cfg files for InnoDB file-per-table tablespaces, then you can do so by preparing the backup as usual without the --export option, and then restoring the backup, and then starting the server. At that point, you can use the server's built-in features to copy the transportable tablespaces.
The restore process for partial backups is quite different than the process for full backups. A partial backup is not a completely functional data directory. The data dictionary in the InnoDB system tablespace will still contain entries for the databases and tables that were not included in the backup.
Rather than using the --copy-back or the --move-back, each individual InnoDB file-per-table tablespace file will have to be manually imported into the target server. The process that is used to import the file will depend on whether partitioning is involved.
To restore individual non-partitioned tables from a backup, find the .ibd and .cfg files for the table in the backup, and then import them using the Importing Transportable Tablespaces for Non-partitioned Tables process.
To restore individual partitions or partitioned tables from a backup, find the .ibd and .cfg files for the partitions in the backup, and then import them using the process.
This page is licensed: CC BY-SA / Gnu FDL
Restore specific tables from a backup. Learn the process of importing individual .ibd files to recover specific tables without restoring the whole database.
When using mariadb-backup, you don't necessarily need to restore every table and/or partition that was backed up. Even if you're starting from a full backup, it is certainly possible to restore only certain tables and/or partitions from the backup, as long as the table or partition involved is in an InnoDB file-per-table tablespace. This page documents how to restore individual tables and partitions.
Before you can restore from a backup, you first need to prepare it to make the data files consistent. You can do so with the --prepare option.
The ability to restore individual tables and partitions relies on InnoDB's transportable tablespaces. For MariaDB to import tablespaces like these, InnoDB looks for a file with a .cfg extension. For mariadb-backup to create these files, you also need to add the --export option during the prepare step.
For example, you might execute the following command:
If this operation completes without error, then the backup is ready to be restored.
Note
mariadb-backup did not support the --export option to begin with. See about that. In earlier versions of MariaDB, this means that mariadb-backup could not create .cfg files for InnoDB file-per-table tablespaces during the --prepare stage. You can still import file-per-table tablespaces without the .cfg files in many cases, so it may still be possible in those versions to restore partial backups or to restore individual tables and partitions with just the .ibd files. If you have a full backup and you need to create .cfg files for InnoDB file-per-table tablespaces, then you can do so by preparing the backup as usual without the --export option, and then restoring the backup, and then starting the server. At that point, you can use the server's built-in features to copy the transportable tablespaces.
The restore process for restoring individual tables and/or partitions is quite different than the process for full backups.
Rather than using the --copy-back or the --move-back, each individual InnoDB file-per-table tablespace file will have to be manually imported into the target server. The process that is used to restore the backup will depend on whether partitioning is involved.
To restore individual non-partitioned tables from a backup, find the .ibd and .cfg files for the table in the backup, and then import them using the Importing Transportable Tablespaces for Non-partitioned Tables process.
To restore individual partitions or partitioned tables from a backup, find the .ibd and .cfg files for the partitions in the backup, and then import them using the process.
This page is licensed: CC BY-SA / Gnu FDL
This guide explains how to create and apply incremental backups with mariadb-backup, saving storage space and reducing backup time.
When using mariadb-backup, you have the option of performing a full or incremental backup. Full backups create a complete copy in an empty directory while incremental backups update a previous backup with new data. This page documents incremental backups.
InnoDB pages contain log sequence numbers, or LSN's. Whenever you modify a row on any InnoDB table on the database, the storage engine increments this number. When performing an incremental backup, mariadb-backup checks the most recent LSN for the backup against the LSN's contained in the database. It then updates any of the backup files that have fallen behind.
In order to take an incremental backup, you first need to take a full backup. In order to back up the database, you need to run mariadb-backup with the --backup option to tell it to perform a backup and with the --target-dir option to tell it where to place the backup files. When taking a full backup, the target directory must be empty or it must not exist.
To take a backup, run the following command:
This backs up all databases into the target directory /var/mariadb/backup. If you look in that directory at the xtrabackup_checkpoints file, you can see the LSN data provided by InnoDB.
For example:
Once you have created a full backup on your system, you can also back up the incremental changes as often as you would like.
In order to perform an incremental backup, you need to run mariadb-backup with the --backup option to tell it to perform a backup and with the --target-dir option to tell it where to place the incremental changes. The target directory must be empty. You also need to run it with the --incremental-basedir option to tell it the path to the full backup taken above. For example:
This command creates a series of delta files that store the incremental changes in /var/mariadb/inc1. You can find a similar xtrabackup_checkpoints file in this directory, with the updated LSN values.
For example:
To perform additional incremental backups, you can then use the target directory of the previous incremental backup as the incremental base directory of the next incremental backup. For example:
Alternatively, you can use the backup history table to manage your backup chain. This allows you to reference the previous backup by a logical name instead of a directory path.
Create the Base Backup: Take a full backup using the --history option.
Create the Incremental Backup: Use --incremental-history-name to specify the base backup's name. It is recommended to use --history again to record this new incremental backup.
You can also use --incremental-history-uuid if you prefer to reference the unique ID generated by mariadb-backup.
--stream outputWhen using --stream, for instance for compression or encryption using external tools, the xtrabackup_checkpoints file containing the information where to continue from on the next incremental backup will also be part of the compressed/encrypted backup file, and so not directly accessible by default.
A directory containing an extra copy of the file can be created using the --extra-lsndir=... option though, and this directory can then be passed to the next incremental backup --incremental-basedir=..., for example:
Following the above steps, you have three backups in /var/mariadb: The first is a full backup, the others are increments on this first backup. In order to restore a backup to the database, you first need to apply the incremental backups to the base full backup. This is done using the --prepare command option.
Perform the following process:
First, prepare the base backup:
Running this command brings the base full backup, that is, /var/mariadb/backup, into sync with the changes contained in the InnoDB redo log collected while the backup was taken.
Then, apply the incremental changes to the base full backup:
Running this command brings the base full backup, that is, /var/mariadb/backup, into sync with the changes contained in the first incremental backup.
For each remaining incremental backup, repeat the last step to bring the base full backup into sync with the changes contained in that incremental backup.
Once you've applied all incremental backups to the base, you can restore the backup using either the --copy-back or the --move-back options. The --copy-back option allows you to keep the original backup files. The --move-back option actually moves the backup files to the datadir, so the original backup files are lost.
First, .
Then, ensure that the datadir is empty.
Then, run mariadb-backup with one of the options mentioned above:
Then, you may need to fix the file permissions.
When mariadb-backup restores a database, it preserves the file and directory privileges of the backup. However, it writes the files to disk as the user and group restoring the database. As such, after restoring a backup, you may need to adjust the owner of the data directory to match the user and group for the MariaDB Server, typically mysql for both. For example, to recursively change ownership of the files to the mysql user and group, you could execute:
Finally, .
This page is licensed: CC BY-SA / Gnu FDL
Get an overview of MariaDB Backup. This section introduces the hot physical backup tool, explaining its capabilities for efficient and consistent backups of your MariaDB Server.
Secure and compress backup streams. Learn to pipe backup output to tools like GPG and GZIP for encryption and storage efficiency.
mariadb-backup supports streaming to stdout with the --stream=xbstream option. This option allows easy integration with popular encryption and compression tools. Below are several examples.
The following example creates an AES-encrypted backup, protected with the password "mypass" and stores it in a file "backup.xb.enc":
To decrypt and unpack this backup into the current directory, the following command can be used:
mariadb-backup backs up the following InnoDB data files:
mariadb-backup will back up tables that use the MyRocks storage engine. This data is located in the directory defined by the rocksdb_datadir system variable. mariadb-backup backs this data up by performing a checkpoint using the rocksdb_create_checkpoint system variable.
mariadb-backup will back up tables that use the MyRocks storage engine.
mariadb-backup also backs up files with the following extensions:
frm
isl
MYD
MYI
MAD
MAI
MRG
TRG
TRN
ARM
ARZ
CSM
CSV
opt
par
mariadb-backup does not back up the files listed below.
This page is licensed: CC BY-SA / Gnu FDL
To tell it which tables to back up, you can use the --tables option.
To tell it which tables to exclude from the backup, you can provide the --tables-exclude option.
To tell it to check a file for specific tables to backup, you can provide the --tables-file option.
This example compresses the backup without encrypting:
We can decompress and unpack the backup as follows:
This example adds a compression step before the encryption, otherwise looks almost identical to the previous example:
We can decrypt, decompress and unpack the backup as follow (note gzip -d in the pipeline):
7zip archiver is a popular utility (especially on Windows) that supports reading from standard output, with the --si option, and writing to stdout with the -so option, and can thus be used together with mariadb-backup.
Compressing backup with the 7z command line utility works as follows:
Uncompress and unpack the archive with
7z also has builtin AES-256 encryption. To encrypt the backup from the previous example using password SECRET, add -pSECRET to the 7z command line.
Compress
Decompress , unpack
Encryption
Decrypt, unpack
Most of the described tools also provide a way to enter a passphrase interactively (although 7zip does not seem to work well when reading input from stdin). Please consult documentation of the tools for more info.
By default files like xtrabackup_checkpoints are also written to the output stream only, and so would not be available for taking further incremental backups without prior extraction from the compressed or encrypted stream output file.
To avoid this these files can additionally be written to a directory that can then be used as input for further incremental backups using the --extra-lsndir=... option.
See also e.g: Combining incremental backups with streaming output
This page is licensed: CC BY-SA / Gnu FDL
Learn how to perform and restore full physical backups of MariaDB databases using the mariadb-backup tool, ensuring consistent data recovery.
When using mariadb-backup, you have the option of performing a full or an incremental backup. Full backups create a complete backup of the database server in an empty directory while incremental backups update a previous backup with whatever changes to the data have occurred since the backup. This page documents how to perform full backups.
In order to back up the database, you need to run mariadb-backup with the --backup option to tell it to perform a backup and with the --target-dir option to tell it where to place the backup files. When taking a full backup, the target directory must be empty or it must not exist.
To take a backup, run the following command:
The time the backup takes depends on the size of the databases or tables you're backing up. You can cancel the backup if you need to, as the backup process does not modify the database.
mariadb-backup writes the backup files the target directory. If the target directory doesn't exist, it creates it. If the target directory exists and contains files, it raises an error and aborts.
Here is an example backup directory:
You can optionally use the --history option to record metadata about your full backup in the database. This creates a centralized log and allows future incremental backups to reference this full backup by name instead of by directory path.
Privileges: The backup user requires INSERT, CREATE, and ALTER privileges on the history table (mysql.mariadb_backup_history in MariaDB 10.11+, or PERCONA_SCHEMA.xtrabackup_history in older versions).
Failure Case: If the user lacks privileges, the backup will complete the file copy process but will fail at the final step with an INSERT command denied error.
The data files that mariadb-backup creates in the target directory are not point-in-time consistent, given that the data files are copied at different times during the backup operation. If you try to restore from these files, InnoDB notices the inconsistencies and crashes to protect you from corruption
Before you can restore from a backup, you first need to prepare it to make the data files consistent. You can do so with the --prepare option.
Run mariadb-backup --backup. You must use a version of mariadb-backup that is compatible with the server version you are planning to upgrade from. For instance, when upgrading from MariaDB 10.4 to 10.5, you must use the 10.4 version of mariadb-backup, Another example: When upgrading from MariaDB 10.6 to 10.11, you must use the 10.6 version of mariadb-backup.
Run mariadb-backup --prepare, again using a compatible version of mariadb-backup, as described in the previous step.
Once the backup is complete and you have prepared the backup for restoration (previous step), you can restore the backup using either the --copy-back or the --move-back options. The --copy-back option allows you to keep the original backup files. The --move-back option actually moves the backup files to the datadir, so the original backup files are lost.
First, stop the MariaDB Server process.
Then, ensure that datadir is empty.
Then, run mariadb-backup with one of the options mentioned above:
Then, you may need to fix the file permissions.
When mariadb-backup restores a database, it preserves the file and directory privileges of the backup. However, it writes the files to disk as the user and group restoring the database. As such, after restoring a backup, you may need to adjust the owner of the data directory to match the user and group for the MariaDB Server, typically mysql for both. For example, to recursively change ownership of the files to the mysql user and group, you could execute:
Finally, start the MariaDB Server process.
Once a full backup is prepared, it is a fully functional MariaDB data directory. Therefore, as long as the MariaDB Server process is stopped on the target server, you can technically restore the backup using any file copying tool, such as cp or rsync. For example, you could also execute the following to restore the backup:
This page is licensed: CC BY-SA / Gnu FDL
Initialize a replication slave using a backup. This guide shows how to use mariadb-backup to provision a new replica from a master server.
This page documents how to set up a replica from a backup.
If you are using MariaDB Galera Cluster, then you may want to try one of the following pages instead:
$ mariadb-backup --backup \
--target-dir=/var/mariadb/backup/ \
--databases='app1 app2' --tables='tab_[0-9]+' \
--user=mariadb-backup --password=mypasswordmariadb-backup --backup --databases="db1" \
--target-dir=/backup --history=partial_db1$ mariadb-backup --prepare --export \
--target-dir=/var/mariadb/backup/mariadb-backup --user=root --backup --stream=xbstream | openssl enc -aes-256-cbc -k mypass > backup.xb.encopenssl enc -d -aes-256-cbc -k mypass -in backup.xb.enc | mbstream -xmariadb-backup --user=root --backup --stream=xbstream | gzip > backupstream.gzgunzip -c backupstream.gz | mbstream -xmariadb-backup --user=root --backup --stream=xbstream | gzip | openssl enc -aes-256-cbc -k mypass > backup.xb.gz.encopenssl enc -d -aes-256-cbc -k mypass -in backup.xb.gz.enc |gzip -d| mbstream -xmariadb-backup --user=root --backup --stream=xbstream | 7z a -si backup.xb.7z7z e backup.xb.7z -so |mbstream -xmariadb-backup --user=root --backup --stream=xbstream | zstd - -o backup.xb.zst -f -1zstd -d backup.xbstream.zst -c | mbstream -xmariadb-backup --user=root --backup --stream=xbstream | gpg -c --passphrase SECRET --batch --yes -o backup.xb.gpggpg --decrypt --passphrase SECRET --batch --yes backup.xb.gpg | mbstream -x$ mariadb-backup --prepare --export \
--target-dir=/var/mariadb/backup/ \
--user=mariadb-backup --password=mypassword$ mariadb-backup --backup \
--target-dir=/var/mariadb/backup/ \
--user=mariadb-backup --password=mypasswordbackup_type = full-backuped
from_lsn = 0
to_lsn = 1635102
last_lsn = 1635102
recover_binlog_info = 0$ mariadb-backup --backup \
--target-dir=/var/mariadb/inc1/ \
--incremental-basedir=/var/mariadb/backup/ \
--user=mariadb-backup --password=mypasswordbackup_type = incremental
from_lsn = 1635102
to_lsn = 1635114
last_lsn = 1635114
recover_binlog_info = 0$ mariadb-backup --backup \
--target-dir=/var/mariadb/inc2/ \
--incremental-basedir=/var/mariadb/inc1/ \
--user=mariadb-backup --password=mypasswordmariadb-backup --backup --target-dir=/full \
--history=full_backup_1mariadb-backup --backup --target-dir=/inc1 \
--incremental-history-name=full_backup_1 \
--history=inc_backup_1# initial full backup
$ mariadb-backup --backup --stream=mbstream \
--user=mariadb-backup --password=mypassword \
--extra-lsndir=backup_base | gzip > backup_base.gz
# incremental backup
$ mariadb-backup --backup --stream=mbstream \
--incremental-basedir=backup_base \
--user=mariadb-backup --password=mypassword \
--extra-lsndir=backup_inc1 | gzip > backup-inc1.gz$ mariadb-backup --prepare \
--target-dir=/var/mariadb/backup$ mariadb-backup --prepare \
--target-dir=/var/mariadb/backup \
--incremental-dir=/var/mariadb/inc1$ mariadb-backup --copy-back \
--target-dir=/var/mariadb/backup/$ chown -R mysql:mysql /var/lib/mysql/The first step is to simply take and prepare a fresh full backup of a database server in the replication topology. If the source database server is the desired replication primary, then we do not need to add any additional options when taking the full backup. For example:
If the source database server is a replica of the desired primary, then we should add the --slave-info option, and possibly the --safe-slave-backup option. For example:
And then we would prepare the backup as you normally would. For example:
Once the backup is done and prepared, we can copy it to the new replica. For example:
At this point, we can restore the backup to the datadir, as you normally would. For example:
And adjusting file permissions, if necessary:
Before the new replica can begin replicating from the primary, we need to create a user account on the primary that the replica can use to connect, and we need to grant the user account the REPLICATION SLAVE privilege. For example:
Before we start the server on the new replica, we need to configure it. At the very least, we need to ensure that it has a unique server_id value. We also need to make sure other replication settings are what we want them to be, such as the various GTID system variables, if those apply in the specific environment.
Once configuration is done, we can start the MariaDB Server process on the new replica.
At this point, we need to get the replication coordinates of the primary from the original backup directory.
If we took the backup on the primary, then the coordinates are in the xtrabackup_binlog_info file. If we took the backup on another replica and if we provided the --slave-info option, then the coordinates are in the file xtrabackup_slave_info file.
mariadb-backup dumps replication coordinates in two forms: GTID coordinates and binary log file and position coordinates, like the ones you would normally see from SHOW MASTER STATUS output. We can choose which set of coordinates we would like to use to set up replication.
For example:
Regardless of the coordinates we use, we will have to set up the primary connection using CHANGE MASTER TO and then start the replication threads with START SLAVE.
If we want to use GTIDs, then we will have to first set gtid_slave_pos to the GTID coordinates that we pulled from either the xtrabackup_binlog_info file or the xtrabackup_slave_info file in the backup directory. For example:
And then we would set MASTER_USE_GTID=slave_pos in the CHANGE MASTER TO statement. For example:
If we want to use the binary log file and position coordinates, then we would set MASTER_LOG_FILE and MASTER_LOG_POS in the CHANGE MASTER TO statement to the file and position coordinates that we pulled; either the xtrabackup_binlog_info file or the xtrabackup_slave_info file in the backup directory, depending on whether the backup was taken from the primary or from a replica of the primary. For example:
We should be done setting up the replica now, so we should check its status with SHOW SLAVE STATUS. For example:
This page is licensed: CC BY-SA / Gnu FDL
Connect to mysqld instance, find out important variables (datadir, InnoDB pagesize, encryption keys, encryption plugin etc)
Scan the database directory, datadir, looking for InnoDB tablespaces, load the tablespaces (basically, it is an “open” in InnoDB sense)
If --lock-ddl-per-table is used:
Do MDL locks, for InnoDB tablespaces that we want to copy. This is to ensure that there are no ALTER, RENAME , TRUNCATE or DROP TABLE on any of the tables that we want to copy.
This is implemented with:
If lock-ddl-per-table is not done, then mariadb-backup would have to know all tables that were created or altered during the backup. See MDEV-16791.
Start a dedicated thread in mariadb-backup to copy InnoDB redo log (ib_logfile*).
This is needed to record all changes done while the backup is running. (The redo log logically is a single circular file, split into innodb_log_files_in_group files.)
The log is also used to see detect if any truncate or online alter tables are used.
The assumption is that the copy thread are able to keep up with server. It should always be able keep up, if the redo log is big enough.
Copy all selected tablespaces, file by file, in dedicated threads in mariadb-backup without involving the mysqld server.
This is special “careful” copy, it looks for page-level consistency by checking the checksum.
The files are not point-in-time consistent as data may change during copy.
The idea is that InnoDB recovery would make it point-in-time consistent.
Execute FLUSH TABLE WITH READ LOCK. This is default, but may be omitted with the -–no-lock parameter. The reason why FLUSH is needed is to ensure that all tables are in a consistent state at the exact same point in time, independent of storage engine.
If --lock-ddl-per-table is used and there is a user query waiting for MDL, the user query are killed to resolve a deadlock. Note that these are only queries of type ALTER, DROP, TRUNCATE or RENAME TABLE. ()
Copy .frm, MyISAM, Aria and other storage engine files.
If MyRocks is used, create rocksdb checkpoint via the set rocksdb_create_checkpoint=$rocksdb_data_dir/mariadb-backup_rocksdb_checkpoint command. The result of it is a directory with hardlinks to MyRocks files. Copy the checkpoint directory to the backup (or create hardlinks in backup directory is on the same partition as data directory). Remove the checkpoint directory.
Copy tables that were created while the backup was running and do rename files that were changed during backup (since ).
Copy the rest of InnoDB redo log, stop redo-log-copy thread.
Write some metadata info (binlog position).
If FLUSH TABLE WITH READ LOCK was done:
execute: UNLOCK TABLES
If --lock-ddl-per-table was done:
execute COMMIT
If log tables exists:
Take MDL lock for log tables
Copy part of log tables that wasn't copied before
Unlock log tables
If FLUSH TABLE WITH READ LOCK is not used, only InnoDB tables are consistent (not the privilege tables in the mysql database or the binary log). The backup point depends on the content of the redo log within the backup itself.
This page is licensed: CC BY-SA / Gnu FDL
Understand backup locking stages. This page explains how mariadb-backup uses BACKUP STAGE commands to minimize locking during operation.
The commands are a set of commands to make it possible to make an efficient external backup tool. How mariadb-backup uses these commands depends on whether you are using the version that is bundled with MariaDB Community Server or the version that is bundled with MariaDB Enterprise Server.
BACKUP STAGE Commands in MariaDB Community ServerThe commands are supported. However, the version of mariadb-backup that is bundled with MariaDB Community Server does not yet use the BACKUP STAGE
$ mariadb-backup --backup \
--target-dir=/var/mariadb/backup/ \
--user=mariadb-backup --password=mypassword$ mariadb-backup --backup \
--slave-info --safe-slave-backup \
--target-dir=/var/mariadb/backup/ \
--user=mariadb-backup --password=mypassword$ mariadb-backup --prepare \
--target-dir=/var/mariadb/backup/$ rsync -avP /var/mariadb/backup dbserver2:/var/mariadb/backup$ mariadb-backup --copy-back \
--target-dir=/var/mariadb/backup/$ chown -R mysql:mysql /var/lib/mysql/CREATE USER 'repl'@'dbserver2' IDENTIFIED BY 'password';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'dbserver2';mariadb-bin.000096 568 0-1-2$ cat xtrabackup_binlog_info
mariadb-bin.000096 568 0-1-2SET GLOBAL gtid_slave_pos = "0-1-2";
CHANGE MASTER TO
MASTER_HOST="dbserver1",
MASTER_PORT=3306,
MASTER_USER="repl",
MASTER_PASSWORD="password",
MASTER_USE_GTID=slave_pos;
START SLAVE;CHANGE MASTER TO
MASTER_HOST="dbserver1",
MASTER_PORT=3306,
MASTER_USER="repl",
MASTER_PASSWORD="password",
MASTER_LOG_FILE='mariadb-bin.000096',
MASTER_LOG_POS=568;
START SLAVE;SHOW SLAVE STATUS\GBEGIN
FOR EACH affected TABLE
SELECT 1 FROM <TABLE> LIMIT 0$ mariadb-backup --backup \
--target-dir=/var/mariadb/backup/ \
--user=mariadb-backup --password=mypassword$ ls /var/mariadb/backup/
aria_log.0000001 mysql xtrabackup_checkpoints
aria_log_control performance_schema xtrabackup_info
backup-my.cnf test xtrabackup_logfile
ibdata1 xtrabackup_binlog_info$ mariadb-backup --backup \
--target-dir=/var/mariadb/backup/ \
--user=mariadb-backup --password=mypassword \
--history=full_backup_weekly$ mariadb-backup --prepare \
--target-dir=/var/mariadb/backup/$ mariadb-backup --copy-back \
--target-dir=/var/mariadb/backup/$ chown -R mysql:mysql /var/lib/mysql/$ rsync -avrP /var/mariadb/backup /var/lib/mysql/
$ chown -R mysql:mysql /var/lib/mysql/BACKUP STAGEWhen the backup is complete, it executes the following BACKUP STAGE statement to unlock the database:
If you would like to use a version of mariadb-backup that uses the BACKUP STAGE statements in the most efficient way, your best option is to use MariaDB Backup that is bundled with MariaDB Enterprise Server.
Copy some transactional tables.
InnoDB (i.e. ibdataN and file extensions .ibd and .isl)
Copy the tail of some transaction logs.
The tail of the InnoDB redo log (i.e. ib_logfileN files) are copied for InnoDB tables.
mariadb-backup from MariaDB Community Server does not currently perform any tasks in the START stage.
mariadb-backup from MariaDB Community Server does not currently perform any tasks in the FLUSH stage.
mariadb-backup from MariaDB Community Server does not currently perform any tasks in the BLOCK_DDL stage.
mariadb-backup from MariaDB Community Server performs the following tasks in the BLOCK_COMMIT stage:
Copy other files.
i.e. file extensions .frm, .isl, .TRG, .TRN, .opt, .par
Copy some transactional tables.
Aria (i.e. aria_log_control and file extensions .MAD and .MAI)
Copy the non-transactional tables.
MyISAM (i.e. file extensions .MYD and .MYI)
MERGE (i.e. file extensions .MRG)
Create a MyRocks checkpoint using the rocksdb_create_checkpoint system variable.
Copy the tail of some transaction logs.
The tail of the InnoDB redo log (i.e. ib_logfileN files) are copied for InnoDB tables.
Save the binary log position to xtrabackup_binlog_info.
Save the Galera Cluster state information to xtrabackup_galera_info.
mariadb-backup from MariaDB Community Server performs the following tasks in the END stage:
Copy the MyRocks checkpoint into the backup.
The following sections describe how the MariaDB Backup version of mariadb-backup that is bundled with MariaDB Enterprise Server uses each BACKUP STAGE command in an efficient way.
mariadb-backup from MariaDB Enterprise Server performs the following tasks in the START stage:
Copy all transactional tables.
InnoDB (i.e. ibdataN and file extensions .ibd and .isl)
Aria (i.e. aria_log_control and file extensions .MAD and .MAI)
Copy the tail of all transaction logs.
The tail of the InnoDB redo log (i.e. ib_logfileN files) are copied for InnoDB tables.
The tail of the Aria redo log (i.e. aria_log.N files) are copied for Aria tables.
mariadb-backup from MariaDB Enterprise Server performs the following tasks in the FLUSH stage:
Copy all non-transactional tables that are not in use. This list of used tables is found with SHOW OPEN TABLES.
MyISAM (i.e. file extensions .MYD and .MYI)
MERGE (i.e. file extensions .MRG)
ARCHIVE (i.e. file extensions .ARM and .ARZ)
CSV (i.e. file extensions .CSM and .CSV)
Copy the tail of all transaction logs.
The tail of the InnoDB redo log (i.e. ib_logfileN files) are copied for InnoDB tables.
The tail of the Aria redo log (i.e. aria_log.N files) are copied for Aria tables.
mariadb-backup from MariaDB Enterprise Server performs the following tasks in the BLOCK_DDL stage:
Copy other files.
i.e. file extensions .frm, .isl, .TRG, .TRN, .opt, .par
Copy the non-transactional tables that were in use during BACKUP STAGE FLUSH.
MyISAM (i.e. file extensions .MYD and .MYI)
MERGE (i.e. file extensions .MRG)
Check ddl.log for DDL executed before the BLOCK DDL stage.
The file names of newly created tables can be read from ddl.log.
The file names of dropped tables can also be read from ddl.log.
Copy changes to system log tables.
mysql.general_log
mysql.slow_log
This is easy as these are append only.
Copy the tail of all transaction logs.
The tail of the InnoDB redo log (i.e. ib_logfileN files) are copied for InnoDB tables.
The tail of the Aria redo log (i.e. aria_log.N files) are copied for Aria tables.
mariadb-backup from MariaDB Enterprise Server performs the following tasks in the BLOCK_COMMIT stage:
Create a MyRocks checkpoint using the rocksdb_create_checkpoint system variable.
Copy changes to system log tables.
mysql.general_log
mysql.slow_log
This is easy as these are append only.
Copy changes to statistics tables.
mysql.table_stats
mysql.column_stats
mysql.index_stats
Copy the tail of all transaction logs.
The tail of the InnoDB redo log (i.e. ib_logfileN files) are copied for InnoDB tables.
The tail of the Aria redo log (i.e. aria_log.N files) are copied for Aria tables.
Save the binary log position to xtrabackup_binlog_info.
Save the Galera Cluster state information to xtrabackup_galera_info.
mariadb-backup from MariaDB Enterprise Server performs the following tasks in the END stage:
Copy the MyRocks checkpoint into the backup.
This page is licensed: CC BY-SA / Gnu FDL
Restore a single database from a full backup. Learn the procedure to extract and recover a specific database schema from a larger backup set.
This method is to solve a flaw with mariadb-backup; it cannot do single database restores from a full backup easily. There is a blog post that details a way to do this, but it's a manual process which is fine for a few tables but if you have hundreds or even thousands of tables then it would be impossible to do quickly.
We can't just move the data files to the datadir as the tables are not registered in the engines, so the database will error. Currently, the only effective method is to a do full restore in a test database and then dump the database that requires restoring or running a partial backup.
This has only been tested with InnoDB. Also, if you have stored procedures or triggers then these will need to be deleted and recreated.
Some of the issues that this method overcomes:
Tables not registered in the InnoDB engine so will error when you try to select from a table if you move the data files into the datadir
Tables with foreign keys need to be created without keys, otherwise it will error when you discard the tablespace
Below is the process to perform a single database restore.
Firstly, we will need the table structure from a mariadb-dump backup with the --no-data option. I recommend this is done at least once per day or every six hours via a cronjob. As it is just the structure, it are very fast.
Using SED to return only the table structure we require, then use vim or another text editor to make sure nothing is left.
Prepare the backup with any incremental-backup-and-restores that you have, and then run the following on the full backup folder using the --export option to generate files with .cfg extensions which InnoDB will look for.
Once we have done these steps, we can then import the table structure. If you have used the --all-databases option, then you will need to either use SED or open it in a text editor and export out tables that you require. You will also need to log in to the database and create the database if the dump file doesn't. Run the following command below:
Once the structure is in the database, we have now registered the tables to the engine. Next, we will run the following statements in the information_schema database, to export statements to import/discard table spaces and drop and create foreign keys which we will use later. (edit the CONSTRAINT_SCHEMA and TABLE_SCHEMA WHERE clause to the database you are restoring. Also, add the following lines after your SELECT and before the FROM to have MariaDB export the files to the OS)
The following are the statements that we will need later.
Once we have run those statements, and they have been exported to a Linux directory or copied from a GUI interface.
Run the ALTER DROP KEYS statements in the database.
Once completed, run the DROP TABLE SPACE statements in the database:
Exit out the database and change into the directory of the full backup location. Run the following commands to copy all the .cfg and .ibd files to the datadir such as /var/lib/mysql/testdatabase (change the datadir location if needed). Learn more about files that mariadb-backup generates with files-created-by-mariadb-backup.
After moving the files, it is very important that MySQL is the owner of the files, otherwise it won't have access to them and will error when we import the tablespaces.
Run the import table spaces statements in the database.
Run the add key statements in the database
We have successfully restored a single database. To test that this has worked, we can do a basic check on some tables.
If you have a primary-replica set up, it would be best to follow the sets above for the primary node and then either take a full mariadb-dump or take a new full mariadb-backup and restore this to the replica. You can find more information about restoring a replica with mariadb-backup in Setting up a Replica with mariadb-backup
After running the below command, copy to the replica and use the LESS linux command to grab the change master statement. Remember to follow this process: Stop replica > restore data > run CHANGE MASTER statement > start replica again.
Please follow Setting up a Replica with mariadb-backup on restoring a replica with mariadb-backup:
For this process to work with Galera cluster, we first need to understand that some statements are not replicated across Galera nodes. One of which is the DISCARD and IMPORT for ALTER TABLES statements, and these statements will need to be ran on all nodes. We also need to run the OS level steps on each server as seen below.
Run the ALTER DROP KEYS statements on ONE NODE as these are replicated.
Once completed, run the DROP TABLE SPACE statements on EVERY NODE, as these are not replicated.
Exit out the database and change into the directory of the full backup location. Run the following commands to copy all the .cfg and .ibd files to the datadir such as /var/lib/mysql/testdatabase (change the datadir location if needed). Learn more about files that mariadb-backup generates with files-created-by-mariadb-backup. This step needs to be done on all nodes. You will need to copy the backup files to each node, we can use the same backup on all nodes.
After moving the files, it is very important that MySQL is the owner of the files, otherwise it won't have access to them and will error when we import the tablespaces.
Run the import table spaces statements on EVERY NODE.
Run the add key statements on ONE NODE.
This page is licensed: CC BY-SA / Gnu FDL
An introduction to the mariadb-backup utility, detailing its features, installation process, and support for hot online backups of InnoDB tables.
mariadb-backup is an open source tool provided by MariaDB for performing physical online backups of InnoDB, Aria and MyISAM tables. For InnoDB, “hot online” backups are possible. It was originally forked from Percona XtraBackup 2.3.8. It is available on Linux and Windows.
This tool provides a production-quality, nearly non-blocking method for performing full backups on running systems. While partial backups with mariadb-backup are technically possible, they require many steps and cannot be restored directly onto existing servers containing other data.
mariadb-backup supports all of the main features of Percona XtraBackup 2.3.8, plus:
BACKUP STAGE START;
BACKUP STAGE BLOCK_COMMIT;BACKUP STAGE END;ARCHIVE (i.e. file extensions .ARM and .ARZ)
CSV (i.e. file extensions .CSM and .CSV)
ARCHIVE (i.e. file extensions .ARM and .ARZ)
CSV (i.e. file extensions .CSM and .CSV)
The file names of renamed tables can also be read from ddl.log, so the files can be renamed instead of re-copying them.
mariadb-dump -u root -p --all-databases --no-data > nodata.sqlsed -n '/Current Database: `DATABASENAME`/, /Current Database:/p' nodata.sql > trimednodata.sql
vim trimednodata.sqlmariadb-backup --prepare --export --target-dir=/media/backups/fullbackupfoldermysql -u root -p schema_name < nodata.sqlSELECT ...
INTO OUTFILE '/tmp/filename.SQL'
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
FROM ...USE information_schema;
SELECT concat("ALTER TABLE ",table_name," DISCARD TABLESPACE;") AS discard_tablespace
FROM information_schema.tables
WHERE TABLE_SCHEMA="DATABASENAME";
SELECT concat("ALTER TABLE ",table_name," IMPORT TABLESPACE;") AS import_tablespace
FROM information_schema.tables
WHERE TABLE_SCHEMA="DATABASENAME";
SELECT
CONCAT ("ALTER TABLE ", rc.CONSTRAINT_SCHEMA, ".",rc.TABLE_NAME," DROP FOREIGN KEY ", rc.CONSTRAINT_NAME,";") AS drop_keys
FROM REFERENTIAL_CONSTRAINTS AS rc
WHERE CONSTRAINT_SCHEMA = 'DATABASENAME';
SELECT
CONCAT ("ALTER TABLE ",
KCU.CONSTRAINT_SCHEMA, ".",
KCU.TABLE_NAME,"
ADD CONSTRAINT ",
KCU.CONSTRAINT_NAME, "
FOREIGN KEY ", "
(`",KCU.COLUMN_NAME,"`)", "
REFERENCES `",REFERENCED_TABLE_NAME,"`
(`",REFERENCED_COLUMN_NAME,"`)" ,"
ON UPDATE " ,(SELECT UPDATE_RULE FROM REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_NAME = KCU.CONSTRAINT_NAME AND CONSTRAINT_SCHEMA = KCU.CONSTRAINT_SCHEMA),"
ON DELETE ",(SELECT DELETE_RULE FROM REFERENTIAL_CONSTRAINTS WHERE CONSTRAINT_NAME = KCU.CONSTRAINT_NAME AND CONSTRAINT_SCHEMA = KCU.CONSTRAINT_SCHEMA),";") AS add_keys
FROM KEY_COLUMN_USAGE AS KCU
WHERE KCU.CONSTRAINT_SCHEMA = 'DATABASENAME'
AND KCU.POSITION_IN_UNIQUE_CONSTRAINT >= 0
AND KCU.CONSTRAINT_NAME NOT LIKE 'PRIMARY';ALTER TABLE schemaname.tablename DROP FOREIGN KEY key_name;
...ALTER TABLE test DISCARD TABLESPACE;
...cp *.cfg /var/lib/mysql
cp *.ibd /var/lib/mysqlsudo chown -R mysql:mysql /var/lib/mysqlALTER TABLE test IMPORT TABLESPACE;
...ALTER TABLE schmeaname.tablename ADD CONSTRAINT key_name FOREIGN KEY (`column_name`) REFERENCES `foreign_table` (`colum_name`) ON UPDATE NO ACTION ON DELETE NO ACTION;
...USE DATABASE
SELECT * FROM test LIMIT 10;mariadb-dump -u user -p --single-transaction --master-data=2 > fullbackup.sql$ mariadb-backup --backup \
--slave-info --safe-slave-backup \
--target-dir=/var/mariadb/backup/ \
--user=mariadb-backup --password=mypasswordALTER TABLE schemaname.tablename DROP FOREIGN KEY key_name;
...ALTER TABLE test DISCARD TABLESPACE;
...cp *.cfg /var/lib/mysql
cp *.ibd /var/lib/mysqlsudo chown -R mysql:mysql /var/lib/mysqlALTER TABLE test IMPORT TABLESPACE;
...ALTER TABLE schmeaname.tablename ADD CONSTRAINT key_name FOREIGN KEY (`column_name`) REFERENCES `foreign_table` (`colum_name`) ON UPDATE NO ACTION ON DELETE NO ACTION;
...Backup/Restore of tables using Data-at-Rest Encryption.
Backup/Restore of tables using InnoDB Page Compression.
with Galera Cluster.
Microsoft Windows support.
Backup/Restore of tables using the MyRocks storage engine. See for more information.
MariaDB Backup supports some additional features, such as:
Minimizes locks during the backup to permit more concurrency and to enable faster backups.
This relies on the usage of BACKUP STAGE commands and DDL logging.
This includes no locking during the copy phase of ALTER TABLE statements, which tends to be the longest phase of these statements.
Provides optimal backup support for all storage engines that store things on local disk.
MariaDB Backup does not support some additional features.
The mariadb-backup executable is included in binary tarballs on Linux.
mariadb-backup can also be installed via a package manager on Linux. Many Linux distributions provide MariaDB software "out of the box", including mariadb-backup. If your Linux distribution doesn't, however, you can install using a MariaDB repository.
In order to do so, your system needs to be configured to install from one of the MariaDB repositories.
You can configure your package manager to install it from MariaDB Corporation's MariaDB Package Repository by using the MariaDB Package Repository setup script.
You can also configure your package manager to install it from MariaDB Foundation's MariaDB Repository by using the MariaDB Repository Configuration Tool.
Installing with yum/dnf
On RHEL, CentOS, Fedora, and other similar Linux distributions, it is highly recommended to install the relevant RPM package from MariaDB's repository using yum or dnf. Starting with RHEL 8 and Fedora 22, yum has been replaced by dnf, which is the next major version of yum. However, yum commands still work on many systems that use dnf. For example:
Installing with apt-get
On Debian, Ubuntu, and other similar Linux distributions, it is highly recommended to install the relevant DEB package from MariaDB's repository using apt-get. For example:
Installing with zypper
On SLES, OpenSUSE, and other similar Linux distributions, it is highly recommended to install the relevant RPM package from MariaDB's repository using zypper. For example:
The mariadb-backup executable is included in MSI and ZIP packages on Windows.
When using the Windows MSI installer, mariadb-backup can be installed by selecting Backup utilities:
The command to use mariadb-backup and the general syntax is:
For in-depth explanations on how to use mariadb-backup, see:
Options supported by mariadb-backup can be found on the mariadb-backup Options page.
mariadb-backup will currently silently ignore unknown command-line options, so be extra careful about accidentally including typos in options or accidentally using options from later mariadb-backup versions. The reason for this is that mariadb-backup currently treats command-line options and options from option files equivalently. When it reads from these option files, it has to read a lot of options from the server option groups read by mariadbd. However, mariadb-backup does not know about many of the options that it normally reads in these option groups. If mariadb-backup raised an error or warning when it encountered an unknown option, then this process would generate a large amount of log messages under normal use. Therefore, mariadb-backup is designed to silently ignore the unknown options instead. See MDEV-18215 about that.
In addition to reading options from the command-line, mariadb-backup can also read options from option files.
The following options relate to how MariaDB command-line tools handles option files. They must be given as the first argument on the command-line:
--print-defaults
Print the program argument list and exit.
--no-defaults
Don't read default options from any option file.
--defaults-file=#
Only read default options from the given option file.
--defaults-extra-file=#
Read this file after the global files are read.
--defaults-group-suffix=#
In addition to the default option groups, also read option groups with this suffix.
mariadb-backup reads server options from the following option groups from option files:
[mariadb-backup]
Options read by mariadb-backup.
[mariadb-backup]
Options read by mariadb-backup.
[xtrabackup]
Options read by mariadb-backup and Percona XtraBackup.
[server]
Options read by MariaDB Server.
[mysqld]
Options read by mariadbd, which includes both MariaDB Server and MySQL Server (where it is called mysqld).
[mysqld-X.Y]
Options read by a specific version of mysqld, which includes both MariaDB Server and MySQL Server. For example: [mysqld-10.6].
mariadb-backup reads client options from the following option groups from option files:
[mariadb-backup]
Options read by mariadb-backup. Available starting with and .
[mariadb-backup]
Options read by mariadb-backup. Available starting with and
[xtrabackup]
Options read by mariadb-backup and Percona XtraBackup.
[client]
Options read by all MariaDB and MySQL client programs, which includes both MariaDB and MySQL clients. For example, mysqldump.
[client-server]
Options read by all MariaDB client programs and the MariaDB Server. This is useful for options like socket and port, which is common between the server and the clients. Available starting with , , and .
[client-mariadb]
Options read by all MariaDB client programs. Available starting with , , and .
mariadb-backup can optionally track your backup operations in a database table. This provides a centralized audit log and allows you to automate incremental backups by referencing the logical name of the previous backup instead of managing file paths.
Table Location and Schema Changes (MariaDB 10.11):
MariaDB 10.11 and later: The history table is mysql.mariadb_backup_history and uses the InnoDB storage engine (transactional).
MariaDB 10.10 and earlier: The history table is PERCONA_SCHEMA.xtrabackup_history and uses the CSV storage engine.
mariadb-backup needs to authenticate with the database server when it performs a backup operation (i.e. when the --backup option is specified). For most use cases, the user account that performs the backup needs to have the following global privileges on the database server.
The required privileges are:
The required privileges are:
If your database server is also using the MyRocks storage engine, then the user account that performs the backup will also need the SUPER global privilege. This is because mariadb-backup creates a checkpoint of this data by setting the rocksdb_create_checkpoint system variable, which requires this privilege. See MDEV-20577 for more information.
CONNECTION ADMIN is also required where --kill-long-queries-timeout is greater than 0, and --no-lock isn't applied in order to KILL queries.
REPLICA MONITOR (or alias SLAVE MONITOR) is also required where --galera-info or --slave-info is specified.
To use the --history option(or the incremental history options), the backup user requires specific privileges on the history table.
The user needs INSERT to create history records and SELECT to read them for incremental backups:
The user needs privileges on the legacy PERCONA_SCHEMA:
For Upgrading to 10.11 (One-Time Migration)
If upgrading from an older version, mariadb-backup will attempt to migrate the old table to the new location on the first run. The backup user needs privileges to move and modify the old table:
Alternatively, you can perform this migration manually before running the backup:
The user account information can be specified with the --user and --password command-line options. For example:
The user account information can also be specified in a supported client option group in an option file. For example:
mariadb-backup does not need to authenticate with the database server when preparing or restoring a backup.
mariadb-backup has to read MariaDB's files from the file system. Therefore, when you run mariadb-backup as a specific operating system user, you should ensure that user account has sufficient permissions to read those files.
If you are using Linux and if you installed MariaDB with a package manager, then MariaDB's files will probably be owned by the mysql user and the mysql group.
mariadb-backup supports Data-at-Rest Encryption.
mariadb-backup will query the server to determine which key management and encryption plugin is being used, and then it will load that plugin itself, which means that mariadb-backup needs to be able to load the key management and encryption plugin's shared library.
mariadb-backup will also query the server to determine which encryption keys it needs to use.
In other words, mariadb-backup is able to figure out a lot of encryption-related information on its own, so normally one doesn't need to provide any extra options to backup or restore encrypted tables.
mariadb-backup backs up encrypted and unencrypted tables as they are on the original server. If a table is encrypted, then the table will remain encrypted in the backup. Similarly, if a table is unencrypted, then the table will remain unencrypted in the backup.
The primary reason that mariadb-backup needs to be able to encrypt and decrypt data is that it needs to apply InnoDB redo log records to make the data consistent when the backup is prepared. As a consequence, mariadb-backup does not perform many encryption or decryption operations when the backup is initially taken. MariaDB performs more encryption and decryption operations when the backup is prepared. This means that some encryption-related problems (such as using the wrong encryption keys) may not become apparent until the backup is prepared.
The mariadb-backup SST method uses the mariadb-backup utility for performing SSTs. See for more information.
mariadb-backup backs up many different files in order to perform its backup operation. See Files Backed up by mariadb-backup for a list of these files.
mariadb-backup creates several different types of files during the backup and prepare phases. See Files Created by mariadb-backup for a list of these files.
mariadb-backup can store the binary log position in the backup. See --binlog-info. This can be used for point-in-time recovery and to use the backup to setup a slave with the correct binlog position.
mariadb-backup defaults to the server's default datadir value. See MDEV-12956 for more information.
If mariadb-backup uses more file descriptors than the system is configured to allow, then users can see errors like the following:
mariadb-backup throws an error and aborts when this error is encountered. See MDEV-19060 for more information.
When this error is encountered, one solution is to explicitly specify a value for the --open-files-limit option either on the command line or in one of the supported server option group s in an option file. For example:
An alternative solution is to set the soft and hard limits for the user account that runs mariadb-backup by adding new limits to /etc/security/limits.conf. For example, if mariadb-backup is run by the mysql user, then you could add lines like the following:
After the system is rebooted, the above configuration should set new open file limits for the mysql user, and the user's ulimit output should look like the following:
How to backup with MariaDB (video)
MariaDB point-in-time recovery (video)
mariadb-backup and Restic (video)
This page is licensed: CC BY-SA / Gnu FDL
Reference of files generated during backup. This page explains the purpose of metadata files like xtrabackup_checkpoints created by the tool.
mariadb-backup creates the following files:
backup-my.cnfDuring the backup, any server options relevant to mariadb-backup are written to the backup-my.cnf option file, so that they can be re-read later during the --prepare stage.
ib_logfile0mariadb-backup creates an empty InnoDB redo log file called ib_logfile0 as part of the --prepare stage. This file has 3 roles:
In the source server, ib_logfile0 is the first (and possibly the only) InnoDB redo log file.
In the non-prepared backup, ib_logfile0 contains all of the InnoDB redo log copied during the backup.
During the --prepare stage, ib_logfile0 is initialized as an empty InnoDB redo log file. That way, if the backup is manually restored, any pre-existing InnoDB redo log files get overwritten by the empty one. This helps to prevent certain kinds of known issues.
mariadb_backup_binlog_infoThis file stores the binary log file name and position that corresponds to the backup.
This file also stores the value of the system variable that correspond to the backup, like this:
The values in this file are only guaranteed to be consistent with the backup if the option was not provided when the backup was taken.
mariadb_backup_binlog_pos_innodbThis file is created by mariadb-backup to provide the binary log file name and position when the --no-lock option is used. It can be used instead of the xtrabackup_binlog_info file to obtain transactionally consistent binlog coordinates from the backup of a master server with the --no-lock option to minimize the impact on a running server.
Whenever a transaction is committed inside InnoDB when the binary log is enabled, the corresponding binlog coordinates are written to the InnoDB redo log along with the transaction commit. This allows one to restore the binlog coordinates corresponding to the last commit done by InnoDB along with a backup.
backup_typeIf the backup is a non-prepared full backup or a non-prepared partial backup, then backup_type is set to full-backuped.
If the backup is a non-prepared incremental backup, then backup_type is set to incremental.
If the backup has already been prepared, then backup_type is set to log-applied.
from_lsnIf backup_type is full-backuped, then from_lsn has the value of 0.
If backup_type is incremental, then from_lsn has the value of the log sequence number (LSN) at which the backup started reading from the InnoDB redo log. This is internally used by mariadb-backup when preparing incremental backups.
This value can be manually set during an incremental backup with the --incremental-lsn option. However, it is generally better to let mariadb-backup figure out the from_lsn automatically by specifying a parent backup with the --incremental-basedir option.
to_lsnto_lsn has the value of the log sequence number (LSN) of the last checkpoint in the InnoDB redo log. This is internally used by mariadb-backup when preparing incremental backups.
last_lsnlast_lsn has the value of the last log sequence number (LSN) read from the InnoDB redo log. This is internally used by mariadb-backup when preparing incremental backups.
uuidIf a UUID was provided by the --incremental-history-uuid option, then it are saved here. Otherwise, this is the empty string.
nameIf a name was provided by the --history or the ---incremental-history-name options, then it are saved here. Otherwise, this is the empty string.
tool_nameThe name of the mariadb-backup executable that performed the backup. This is generally mariadb-backup.
tool_commandThe arguments that were provided to mariadb-backup when it performed the backup.
tool_versionThe version of mariadb-backup that performed the backup.
ibbackup_versionThe version of mariadb-backup that performed the backup.
server_versionThe version of MariaDB Server that was backed up.
start_timeThe time that the backup started.
end_timeThe time that the backup ended.
lock_timeThe amount of time that mariadb-backup held its locks.
binlog_posThis field stores the binary log file name and position that corresponds to the backup.
This field also stores the value of the gtid_current_pos system variable that correspond to the backup.
The values in this field are only guaranteed to be consistent with the backup if the --no-lock option was not provided when the backup was taken.
innodb_from_lsnThis is identical to from_lsn in xtrabackup_checkpoints.
If the backup is a full backup, then innodb_from_lsn has the value of 0.
If the backup is an incremental backup, then innodb_from_lsn has the value of the log sequence number (LSN) at which the backup started reading from the InnoDB redo log.
innodb_to_lsnThis is identical to to_lsn in xtrabackup_checkpoints.
innodb_to_lsn has the value of the log sequence number (LSN) of the last checkpoint in the InnoDB redo log.
partialIf the backup is a partial backup, then this value are Y.
Otherwise, this value are N.
incrementalIf the backup is an incremental backup, then this value are Y.
Otherwise, this value are N.
formatThis field's value is the format of the backup.
If the --stream option was set to xbstream, then this value are xbstream.
If the --stream option was not provided, then this value are file.
compressedIf the --compress option was provided, then this value are compressed.
Otherwise, this value are N.
mariadb_backup_slave_infoIf the --slave-info option is provided, this file contains the CHANGE MASTER command that can be used to set up a new server as a slave of the original server's master after the backup has been restored.
mariadb-backup does not check if GTIDs are being used in replication. It takes a shortcut and assumes that if the system variable is non-empty, then it writes the CHANGE MASTER
<table>.deltaIf the backup is an incremental backup, this file contains changed pages for the table.
<table>.delta.metaIf the backup is an incremental backup, this file contains metadata about <table>.delta files. The fields in this file are listed below.
page_sizeThis field contains either the value of innodb_page_size or the value of the KEY_BLOCK_SIZE table option for the table if the ROW_FORMAT table option for the table is set to COMPRESSED.
zip_sizeIf the ROW_FORMAT table option for this table is set to COMPRESSED, this field contains the value of the compressed page size.
space_idThis field contains the value of the table's space_id.
This page is licensed: CC BY-SA / Gnu FDL
CREATE USER 'mariadb-backup'@'localhost' IDENTIFIED BY 'mypassword';
GRANT RELOAD, PROCESS, LOCK TABLES, BINLOG MONITOR ON *.* TO 'mariadb-backup'@'localhost';CREATE USER 'mariadb-backup'@'localhost' IDENTIFIED BY 'mypassword';
GRANT RELOAD, PROCESS, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'mariadb-backup'@'localhost';GRANT SELECT, INSERT, CREATE, ALTER ON mysql.mariadb_backup_history TO 'mariadb-backup'@'localhost';GRANT SELECT, INSERT, CREATE, ALTER ON PERCONA_SCHEMA.xtrabackup_history TO 'mariadb-backup'@'localhost';sudo yum install MariaDB-backupsudo apt-get install mariadb-backupsudo zypper install MariaDB-backupmariadb-backup <options>GRANT DROP, ALTER, RENAME ON PERCONA_SCHEMA.xtrabackup_history TO 'mariadb-backup'@'localhost';
GRANT CREATE ON PERCONA_SCHEMA TO 'mariadb-backup'@'localhost';RENAME TABLE PERCONA_SCHEMA.xtrabackup_history TO mysql.mariadb_backup_history;
ALTER TABLE mysql.mariadb_backup_history ENGINE=InnoDB;mariadb-backup --backup \
--target-dir=/var/mariadb/backup/ \
--user=mariadb-backup --password=mypassword[mariadb-backup]
user=mariadb-backup
password=mypassword2019-02-12 09:48:38 7ffff7fdb820 InnoDB: Operating system error number 23 in a file operation.
InnoDB: Error number 23 means 'Too many open files in system'.
InnoDB: Some operating system error numbers are described at
InnoDB: http://dev.mysql.com/doc/refman/5.6/en/operating-system-error-codes.html
InnoDB: Error: could not open single-table tablespace file ./db1/tab1.ibd
InnoDB: We do not continue the crash recovery, because the table may become
InnoDB: corrupt if we cannot apply the log records in the InnoDB log to it.
InnoDB: To fix the problem and start mysqld:
InnoDB: 1) If there is a permission problem in the file and mysqld cannot
InnoDB: open the file, you should modify the permissions.
InnoDB: 2) If the table is not needed, or you can restore it from a backup,
InnoDB: then you can remove the .ibd file, and InnoDB will do a normal
InnoDB: crash recovery and ignore that table.
InnoDB: 3) If the file system or the disk is broken, and you cannot remove
InnoDB: the .ibd file, you can set innodb_force_recovery > 0 in my.cnf
InnoDB: and force InnoDB to continue crash recovery here.[mariadb-backup]
open_files_limit=65535mysql soft nofile 65535
mysql hard nofile 65535ulimit -Sn
65535
ulimit -Hn
65535xtrabackup_binlog_infoThis file stores the binary log file name and position that corresponds to the backup.
This file also stores the value of the gtid_current_pos system variable that correspond to the backup, like this:
The values in this file are only guaranteed to be consistent with the backup if the --no-lock option was not provided when the backup was taken.
The limitation of using xtrabackup_binlog_pos_innodb with the --no-lock option is that no DDL or modification of non-transactional tables should be done during the backup. If the last event in the binlog is a DDL/non-transactional update, the coordinates in the file xtrabackup_binlog_pos_innodb are too old. But as long as only InnoDB updates are done during the backup, the coordinates are correct.
xtrabackup_binlog_pos_innodbThis file is created by mariadb-backup to provide the binary log file name and position when the --no-lock option is used. It can be used instead of the xtrabackup_binlog_info file to obtain transactionally consistent binlog coordinates from the backup of a master server with the --no-lock option to minimize the impact on a running server.
Whenever a transaction is committed inside InnoDB when the binary log is enabled, the corresponding binlog coordinates are written to the InnoDB redo log along with the transaction commit. This allows one to restore the binlog coordinates corresponding to the last commit done by InnoDB along with a backup.
The limitation of using xtrabackup_binlog_pos_innodb with the --no-lock option is that no DDL or modification of non-transactional tables should be done during the backup. If the last event in the binlog is a DDL/non-transactional update, the coordinates in the file xtrabackup_binlog_pos_innodb are too old. But as long as only InnoDB updates are done during the backup, the coordinates are correct.
xtrabackup_checkpointsThe xtrabackup_checkpoints file contains metadata about the backup.
For example:
See below for a description of the fields.
If the --extra-lsndir option is provided, then an extra copy of this file are saved in that directory.
xtrabackup_infoContains information about the backup. The fields in this file are listed below.
If the --extra-lsndir option is provided, an extra copy of this file is saved in that directory.
MASTER_USE_GTIDslave_posCHANGE MASTERMASTER_LOG_FILEMASTER_LOG_POSxtrabackup_slave_infoIf the --slave-info option is provided, this file contains the CHANGE MASTER command that can be used to set up a new server as a slave of the original server's master after the backup has been restored.
mariadb-backup does not check if GTIDs are being used in replication. It takes a shortcut and assumes that if the gtid_slave_pos system variable is non-empty, then it writes the CHANGE MASTER command with the MASTER_USE_GTID option set to slave_pos. Otherwise, it writes the CHANGE MASTER command with the MASTER_LOG_FILE and MASTER_LOG_POS options using the master's binary log file and position. See for more information.
xtrabackup_galera_infoIf the --galera-info option is provided, this file contains information about a Galera Cluster node's state.
The file contains the values of the and status variables.
The values are written in the following format:
For example:
mariadb-bin.000096 568 0-1-2mariadb-bin.000096 568 0-1-2[mariadb]
Options read by MariaDB Server.
[mariadb-X.Y]
Options read by a specific version of MariaDB Server. For example: [mariadb-10.6].
[mariadbd]
Options read by MariaDB Server. Available from MariaDB 10.5.4.
[mariadbd-X.Y]
Options read by a specific version of MariaDB Server. For example: [mariadbd-10.6]. Available from MariaDB 10.5.4.
[client-server]
Options read by all MariaDB client programs and the MariaDB Server. This is useful for options like socket and port, which is common between the server and the clients.
[galera]
Options read by MariaDB Server, but only if it is compiled with Galera Cluster support. All builds on Linux are compiled with Galera Cluster support. When using one of these builds, options from this option group are read even if the Galera Cluster functionality is not enabled.

backup_type = full-backuped
from_lsn = 0
to_lsn = 1635102
last_lsn = 1635102
recover_binlog_info = 0backup_type = full-backuped
from_lsn = 0
to_lsn = 1635102
last_lsn = 1635102
recover_binlog_info = 0wsrep_local_state_uuid:wsrep_last_committedd38587ce-246c-11e5-bcce-6bbd0831cc0f:1352215wsrep_local_state_uuid:wsrep_last_committedd38587ce-246c-11e5-bcce-6bbd0831cc0f:1352215