Connection and Privileges Needed¶
Percona XtraBackup needs to be able to connect to the database server and perform operations on the server and the datadir when creating a backup, when preparing in some scenarios and when restoring it. In order to do so, there are privileges and permission requirements on its execution that must be fulfilled.
Privileges refers to the operations that a system user is permitted to do in the database server. They are set at the database server and only apply to users in the database server.
Permissions are those which permits a user to perform operations on the system, like reading, writing or executing on a certain directory or start/stop a system service. They are set at a system level and only apply to system users.
When xtrabackup is used, there are two actors involved: the user invoking the program - a system user - and the user performing action in the database server - a database user. Note that these are different users in different places, even though they may have the same username.
All the invocations of xtrabackup in this documentation assume that the system user has the appropriate permissions and you are providing the relevant options for connecting the database server - besides the options for the action to be performed - and the database user has adequate privileges.
Connecting to the server¶
$ xtrabackup --user=DVADER --password=14MY0URF4TH3R --backup \ --target-dir=/data/bkps/
If you don’t use the
--user option, Percona XtraBackup will assume
the database user whose name is the system user executing it.
Other Connection Options¶
According to your system, you may need to specify one or more of the following options to connect to the server:
|–port||The port to use when connecting to the database server with TCP/IP.|
|–socket||The socket to use when connecting to the local database.|
|–host||The host to use when connecting to the database server with TCP/IP.|
These options are passed to the mysql child process without
mysql --help for details.
In case of multiple server instances, the correct connection parameters (port, socket, host) must be specified in order for xtrabackup to talk to the correct server.
Permissions and Privileges Needed¶
Once connected to the server, in order to perform a backup you will need
EXECUTE permissions at a filesystem level in the
The database user needs the following privileges on the tables/databases to be backed up:
LOCK TABLES(unless the
--no-lockoption is specified) in order to run
FLUSH TABLES WITH READ LOCKand
FLUSH ENGINE LOGSprior to start copying the files, and requires this privilege when Backup Locks are used
BACKUP_ADMINprivilege is needed to query the performance_schema.log_status table, and run
LOCK INSTANCE FOR BACKUP,
LOCK BINLOG FOR BACKUP, or
LOCK TABLES FOR BACKUP.
REPLICATION CLIENTin order to obtain the binary log position,
CREATE TABLESPACEin order to import tables (see Restoring Individual Tables),
PROCESSin order to run
SHOW ENGINE INNODB STATUS(which is mandatory), and optionally to see all threads which are running on the server (see Handling FLUSH TABLES WITH READ LOCK),
SUPERin order to start/stop the slave threads in a replication environment, use XtraDB Changed Page Tracking for Incremental Backups and for handling FLUSH TABLES WITH READ LOCK,
CREATEprivilege in order to create the PERCONA_SCHEMA.xtrabackup_history database and table,
INSERTprivilege in order to add history records to the PERCONA_SCHEMA.xtrabackup_history table,
SELECTprivilege in order to use
--incremental-history-uuidin order for the feature to look up the
innodb_to_lsnvalues in the PERCONA_SCHEMA.xtrabackup_history table.
The explanation of when these are used can be found in How Percona XtraBackup Works.
An SQL example of creating a database user with the minimum privileges required to full backups would be:
mysql> CREATE USER 'bkpuser'@'localhost' IDENTIFIED BY 's3cr%T'; mysql> GRANT BACKUP_ADMIN, PROCESS, RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'bkpuser'@'localhost'; mysql> GRANT SELECT ON performance_schema.log_status TO 'bkpuser'@'localhost'; mysql> FLUSH PRIVILEGES;