0

I'm backupping my databases with automysqlbackup.

This works fine - but unfortunately I do not get a single file for each database but a cumulative file called

daily_all-databases_2016-04-15_12h01m_Friday.sql.gz

.
├── daily
│   └── daily_all-databases_2016-04-15_12h01m_Friday.sql.gz
├── latest
├── monthly
├── tmp
└── weekly

I would like to get a single archive for each database.

How can I do that?

MyFault
  • 913
  • 3
  • 15
  • 36

1 Answers1

2

You should be able to use the SEPDIR config parameter. It will create separate directories for each database, with an own file inside of it.

From the Ubuntu manpage (but should work on CentOS just the same):

SEPDIR=yes
Separate backup directory and file for each DB? (yes or no)

Alternatively, it's very simple to write up a bash script yourself that does this. Something like this should do:

mysql -u user -p pass -B -e "SHOW DATABASES"|sed 1d|while read db
do
    mysqldump -u user -p pass $db|gzip>"/home/db_backup/$db.sql.gz"
    if [[ $? != 0 ]];then
        echo "Backup of database $db FAILED!"
    fi
done

Obviously replace user and pass with their respective values.

Oldskool
  • 2,025
  • 1
  • 16
  • 27
  • Didn't see the `sepdir` parameter on my install, but doing this manually with just `mysqldump` would ignore the advantage of `automysqlbackup` in the form of incremental backups with automatic rename and deletion of old files. – Sven Apr 15 '16 at 10:30
  • @Sven True, it's just an illustration of very simple dumping script. It's just an alternative in case the sepdir parameter doesn't offer what OP is looking for. – Oldskool Apr 15 '16 at 10:32