VaTo
VaTo

Reputation: 3078

xtrabackup only performs a full back up if is executed with super user privileges

According to this link, I executed this command to backup my database:

 xtrabackup --backup --databases='database' --target-dir=/home/user/backups --datadir=/var/lib/mysql/

But I get the following error:

160520 02:00:54  version_check Done.
160520 02:00:54 Connecting to MySQL server host: localhost, user: root, password: set, port: 0, socket: /var/lib/mysql/mysql.sock
Using server version 5.5.44-MariaDB
xtrabackup version 2.4.2 based on MySQL server 5.7.11 Linux (x86_64) (revision id: 8e86a84)
xtrabackup: uses posix_fadvise().
xtrabackup: cd to /var/lib/mysql/
xtrabackup: open files limit requested 0, set to 1024
xtrabackup: using the following InnoDB configuration:
xtrabackup:   innodb_data_home_dir = .
xtrabackup:   innodb_data_file_path = ibdata1:10M:autoextend
xtrabackup:   innodb_log_group_home_dir = .
xtrabackup:   innodb_log_files_in_group = 2
xtrabackup:   innodb_log_file_size = 5242880
InnoDB: Number of pools: 1
InnoDB: Operating system error number 13 in a file operation.
InnoDB: The error means mysqld does not have the access rights to the directory.

I solved it by running the same command with sudo, the problem is that the backup directory gets created as root so my user doesn't have access to that directory so I always have to change the ownership recursively for that directory so I can be able to read it. This method isn't pretty efficient to me.

Upvotes: 1

Views: 1911

Answers (3)

Justin Buist
Justin Buist

Reputation: 152

If you get this error after successfully running the backup script for some time and can't figure out what changed look for a new folder under your MySQL directory (usually /var/lib/mysql). I've twice found new DBs created with permissions only at the user level (ie: drwx------) with no group read access. A quick chmod 750 of the directory to fix permissions takes care of it for me.

Upvotes: 1

Eupolemos
Eupolemos

Reputation: 1

I think you're trying to fight the way Percona wants you to use their stuff, though I could be wrong.

I know that innobackupex (perl script installed with xtrabackup) is supposed to be run as root, since one of Percona's support engineers says so here: https://www.percona.com/forums/questions-discussions/percona-xtrabackup/8748-error-trying-to-run-backup

Maybe the xtrabackup command is just supposed to be used the same way?

Upvotes: 0

Yves
Yves

Reputation: 46

The xtrabackup tool runs as the user invoking it and that user must be able to read the database files which are normally owned by mysql:mysql and mode 660.

An easy fix is usually to add the user to the mysql group, for example:

useradd -G mysql yves

Then logout and re-open the session, it should work.

Upvotes: 3

Related Questions