Bug #76122 Access denied on database directory not handled correctly
Submitted: 3 Mar 2015 11:45 Modified: 25 Mar 2015 9:42
Reporter: Daniël van Eeden (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Enterprise Backup Severity:S3 (Non-critical)
Version:3.11.1, 3.12.0 OS:Any
Assigned to: CPU Architecture:Any
Tags: Backup, directory

[3 Mar 2015 11:45] Daniël van Eeden
Description:
An read error (error 13) on a directory is not handled correctly.

Current behaviour:
- Read error is reported when it happens
- Exit status is still 0
- Backup ends with 'mysqlbackup completed OK!'

It should try to handle this inteligently:
- If the directory is 'lost+found': Warn & ignore
- If the directory is hidden (.zfs, .snapshot): Warn & ignore
- All others: return non-zero return code and error.

How to repeat:
I found a server with a datadir which was equal to a mountpoint (instead of a subdirectory on that mountpoint, which is the best practice). The backup log showed errors about lost+found, but returned ok.

A more probable example of this is when the backup user doesn't have equal rights to the user which runs mysqld.

CREATE DATABASE foobar;
USE foobar;
CREATE TABLE t1 (id int);
\! chmod 000 /var/lib/mysql/foobar
\q
mysqlbackup backup
echo $?

Try to find the foobar.t1 table in the backup.
[3 Mar 2015 12:02] Daniël van Eeden
An alternative solution would be to:
Ignore directories according to (select @@ignore_db_dirs) and give errors for all other directories.
[25 Mar 2015 9:42] MySQL Verification Team
Hello Daniël,

Thank you for the report.

Thanks,
Umesh
[25 Mar 2015 9:42] MySQL Verification Team
// chmod -R 000 data/test/

[root@cluster-repo mysql-5.6.24]# ls -l data/test/
total 864276
---------- 1 mysql mysql        65 Feb  3 23:54 db.opt
---------- 1 root  root       8684 Mar 27 16:39 keyvalue.frm
---------- 1 root  root  884998144 Mar 27 16:41 keyvalue.ibd
[root@cluster-repo mysql-5.6.24]#

// Backup initiated

[root@cluster-repo meb-3.12.0]# bin/mysqlbackup --user=root  --with-timestamp --backup-dir=./backup backup
MySQL Enterprise Backup version 3.12.0 Linux-3.8.13-16.2.1.el6uek.x86_64-x86_64 [2015/03/10]
Copyright (c) 2003, 2015, Oracle and/or its affiliates. All Rights Reserved.

 mysqlbackup: INFO: Starting with following command line ...
 bin/mysqlbackup --user=root --with-timestamp --backup-dir=./backup backup

 mysqlbackup: INFO:
 mysqlbackup: INFO: MySQL server version is '5.6.24-enterprise-commercial-advanced'.
 mysqlbackup: INFO: Got some server configuration information from running server.

IMPORTANT: Please check that mysqlbackup run completes successfully.
           At the end of a successful 'backup' run mysqlbackup
           prints "mysqlbackup completed OK!".

150327 16:44:39 mysqlbackup: INFO: MEB logfile created at /data/ushastry/downloads/meb-3.12.0/backup/2015-03-27_16-44-39/meta/MEB_2015-03-27.16-44-39_backup.log

--------------------------------------------------------------------
                       Server Repository Options:
--------------------------------------------------------------------
  datadir = /data/ushastry/server/mysql-5.6.24/data/
  innodb_data_home_dir =
  innodb_data_file_path = ibdata1:12M:autoextend
  innodb_log_group_home_dir = /data/ushastry/server/mysql-5.6.24/data/
  innodb_log_files_in_group = 2
  innodb_log_file_size = 50331648
  innodb_page_size = 16384
  innodb_checksum_algorithm = innodb
  innodb_undo_directory = /data/ushastry/server/mysql-5.6.24/data/
  innodb_undo_tablespaces = 0
  innodb_undo_logs = 128

--------------------------------------------------------------------
                       Backup Config Options:
--------------------------------------------------------------------
  datadir = /data/ushastry/downloads/meb-3.12.0/backup/2015-03-27_16-44-39/datadir
  innodb_data_home_dir = /data/ushastry/downloads/meb-3.12.0/backup/2015-03-27_16-44-39/datadir
  innodb_data_file_path = ibdata1:12M:autoextend
  innodb_log_group_home_dir = /data/ushastry/downloads/meb-3.12.0/backup/2015-03-27_16-44-39/datadir
  innodb_log_files_in_group = 2
  innodb_log_file_size = 50331648
  innodb_page_size = 16384
  innodb_checksum_algorithm = innodb
  innodb_undo_directory = /data/ushastry/downloads/meb-3.12.0/backup/2015-03-27_16-44-39/datadir
  innodb_undo_tablespaces = 0
  innodb_undo_logs = 128

 mysqlbackup: INFO: Unique generated backup id for this is 14274548790938497

 mysqlbackup: INFO: Creating 14 buffers each of size 16777216.
150327 16:44:41 mysqlbackup: INFO: Full Backup operation starts with following threads
                1 read-threads    6 process-threads    1 write-threads
150327 16:44:41 mysqlbackup: INFO: System tablespace file format is Antelope.
150327 16:44:41 mysqlbackup: INFO: Starting to copy all innodb files...
 mysqlbackup: INFO: Could not find binlog index file. binlogs will not be copied for this backup.
 Point-In-Time-Recovery will not be possible.
 If this is online backup then server may not have started with --log-bin.
 You may specify its location with --log-bin-index option.
150327 16:44:41 mysqlbackup: INFO: Found checkpoint at lsn 987443421.
150327 16:44:41 mysqlbackup: INFO: Starting log scan from lsn 987443200.
150327 16:44:41 mysqlbackup: INFO: Copying log...
150327 16:44:41 mysqlbackup: INFO: Copying /data/ushastry/server/mysql-5.6.24/data/ibdata1 (Antelope file format).
150327 16:44:41 mysqlbackup: INFO: Log copied, lsn 987443421.
150327 16:44:44 mysqlbackup: INFO: Copying /data/ushastry/server/mysql-5.6.24/data/mysql/innodb_index_stats.ibd (Antelope file format).
150327 16:44:44 mysqlbackup: INFO: Copying /data/ushastry/server/mysql-5.6.24/data/mysql/innodb_table_stats.ibd (Antelope file format).
150327 16:44:44 mysqlbackup: INFO: Copying /data/ushastry/server/mysql-5.6.24/data/mysql/slave_master_info.ibd (Antelope file format).
150327 16:44:44 mysqlbackup: INFO: Copying /data/ushastry/server/mysql-5.6.24/data/mysql/slave_relay_log_info.ibd (Antelope file format).
150327 16:44:44 mysqlbackup: INFO: Copying /data/ushastry/server/mysql-5.6.24/data/mysql/slave_worker_info.ibd (Antelope file format).
150327 16:44:44 mysqlbackup: INFO: Completing the copy of innodb files.
150327 16:44:45 mysqlbackup: INFO: Preparing to lock tables: Connected to mysqld server.
150327 16:44:45 mysqlbackup: INFO: Starting to lock all the tables...
150327 16:44:45 mysqlbackup: INFO: All tables are locked and flushed to disk
150327 16:44:45 mysqlbackup: INFO: Opening backup source directory '/data/ushastry/server/mysql-5.6.24/data/'
150327 16:44:45 mysqlbackup: INFO: Starting to backup all non-innodb files in
        subdirectories of '/data/ushastry/server/mysql-5.6.24/data/'
150327 16:44:45 mysqlbackup: INFO: Copying the database directory 'mysql'
150327 16:44:45 mysqlbackup: INFO: Copying the database directory 'performance_schema'
150327 16:44:45 mysqlbackup: INFO: Completing the copy of all non-innodb files.
150327 16:44:47 mysqlbackup: INFO: A copied database page was modified at 987443421.
          (This is the highest lsn found on page)
          Scanned log up to lsn 987443421.
          Was able to parse the log up to lsn 987443421.
          Maximum page number for a log record 0
150327 16:44:47 mysqlbackup: INFO: All tables unlocked
150327 16:44:47 mysqlbackup: INFO: All MySQL tables were locked for 1.876 seconds.
150327 16:44:47 mysqlbackup: INFO: Reading all global variables from the server.
150327 16:44:47 mysqlbackup: INFO: Completed reading of all global variables from the server.
150327 16:44:47 mysqlbackup: INFO: Creating server config files server-my.cnf and server-all.cnf in /data/ushastry/downloads/meb-3.12.0/backup/2015-03-27_16-44-39
150327 16:44:47 mysqlbackup: INFO: Full Backup operation completed successfully.
150327 16:44:47 mysqlbackup: INFO: Backup created in directory '/data/ushastry/downloads/meb-3.12.0/backup/2015-03-27_16-44-39'

-------------------------------------------------------------
   Parameters Summary
-------------------------------------------------------------
   Start LSN                  : 987443200
   End LSN                    : 987443421
-------------------------------------------------------------

mysqlbackup completed OK!
[root@cluster-repo meb-3.12.0]# echo $?
0
[root@cluster-repo meb-3.12.0]#

[root@cluster-repo meb-3.12.0]# ls -l backup/2015-03-27_16-44-39/datadir/
total 143372
-rw-r--r-- 1 root root      1024 Mar 27 16:44 ibbackup_logfile
-rw-r--r-- 1 root root 146800640 Mar 27 16:44 ibdata1
drwx------ 2 root root      4096 Mar 27 16:44 mysql
drwx------ 2 root root      4096 Mar 27 16:44 performance_schema
[root@cluster-repo meb-3.12.0]#