Not the answer you need?
Register and ask your own question!

Error: Failed to create backup directory - a common error it seems

wilburunionwilburunion EntrantInactive User Role Beginner
I am sure it must be something I am doing wrong - YES AND SOLVED -

[email protected] [~]# innobackupex --user=xxxxxxxx --password=xxxxxxxx /data/backups (PASSWORD AND USERNAME ARE CORRECT)

RESULTS IN . . .

innobackupex: Error: Failed to create backup directory /data/backups/2016-10-27_21-38-02: No such file or directory at /usr/bin/innobackupex line 386.

THE ENTIRE RUN OUTPUT IS:

[email protected] [~]# innobackupex --user=xxxxxxxx --password=xxxxxxxx /data/backups

InnoDB Backup Utility v1.5.1-xtrabackup; Copyright 2003, 2009 Innobase Oy
and Percona LLC and/or its affiliates 2009-2013. All Rights Reserved.

This software is published under
the GNU GENERAL PUBLIC LICENSE Version 2, June 1991.

161027 21:37:56 innobackupex: Starting mysql with options: --password=xxxxxxxx --user='xxxxxxxxx' --unbuffered --
161027 21:37:56 innobackupex: Connected to database with mysql child process (pid=20561)
161027 21:38:02 innobackupex: Connection to database server closed
IMPORTANT: Please check that the backup run completes successfully.
At the end of a successful backup run innobackupex
prints "completed OK!".

innobackupex: Using mysql Ver 15.1 Distrib 10.0.27-MariaDB, for Linux (x86_64) using readline 5.1
innobackupex: Using mysql server version Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

innobackupex: Error: Failed to create backup directory /data/backups/2016-10-27_21-38-02: No such file or directory at /usr/bin/innobackupex line 386.
[email protected] [~]#

I installed this via YUM -> yum install xtrabackup

[email protected] [~]# rpm -qa | grep -i percona
percona-xtrabackup-20-2.0.8-587.rhel6.x86_64
[email protected] [~]#

it seems i connect . . . and then I do not know if the connection closes because of the directory fail or the other way around

I have googled this and looked at many other similar errors but nothing pointing to this specific line in the script

This happens whether the /data/backups directory exists or not (with 755 permissions) and the datadir is set in my.cnf

anyone knowledgeable on this ??

--- EDIT --- EDIT --- EDIT ---

It appears this is a permissions problem - and happened because no superuser permissions existed for Percona xtrabackup and the data directory was not preoperly prepared - as the Percona xtrabackup manual at 4.2 page 17 is not detailed on how to get a SETUP of xtrabackup done so it works. this below will work on most 'nix based boxes including CentOS and Unbuntu

Before using XtraBackup for the first time, prepare the system and MySQL user that XtraBackup will use. This section covers the initial preparation.

System User


Unless you plan on using the system root user, you must perform some basic preparations to ensure that XtraBackup can be executed properly. It is assumed that you are logged in as the user that will run XtraBackup, and that it has superuser privileges.

Add your system user to the "mysql" group (substitute in your actual username):
  • sudo gpasswd -a username mysql
and create the directory that will be used for storing the backups that XtraBackup creates:
  • sudo mkdir -p /data/backups
  • sudo chown -R username: /data
The chown command ensures that the user will be able to write to the backups directory.

MySQL User


XtraBackup requires a MySQL user that it will use when creating backups. Let's create one now.

Enter the MySQL console with this command:
  • mysql -u root -p
Supply the MySQL root password. If you are running on a cPanel/WHM system - you will need to initially set the mysql user root password in mysql services and restart the MySQL server for it to take effect if you have not already done so. The initial MySQL cPanel/WHM root password is a randomly generated string the system knows and uses

At the MySQL prompt, create a new MySQL user and assign it a password. In this example, the user is called "bkpuser" and the password is "bkppassword". Change both of these to something secure:
  • CREATE USER 'bkpuser'@'localhost' IDENTIFIED BY 'bkppassword';
Next, grant the new MySQL user reload, lock, and replication privileges to all of the databases:
  • GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'bkpuser'@'localhost';
  • FLUSH PRIVILEGES;
These are the minimum required privileges that XtraBackup needs to create full backups of databases.

When you are finished, exit the MySQL console:
  • exit
Update Datadir Permissions
SINCE data files in this example are stored in /var/lib/mysql, which is sometimes referred to as a datadir. By default, access to the datadir is restricted to the mysql user. XtraBackup requires access to this directory to create its backups, so you need to run the below commands to ensure that the system user set up earlier—as a member of the mysql group—has the proper permissions:
  • sudo chown -R mysql: /var/lib/mysql
  • sudo find /var/lib/mysql -type d -exec chmod 770 "{}" \;
These commands ensure that all of the directories in the datadir are accessible to the mysql group, and should be run prior to each backup.


Now you are ready to create a full backup of the databases.
Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.