logrotate mysql dump

Technique logrotate mysql dump

I chose to use logrotate to execute a copy with rotation and auto purge “of database dumps over which files they need my sites.

In this example I run up to a mysql with mysqldump daily, and cherish the previous 8 with this method.

Let’s see how:

1. Create a file as you wish: mysql-bkup.

We will make copies of all the databases in a single dump. Certainly be staying out of this bath your mysql password.

Vim/etc/logrotate.d/mysql-bkup
/var/backups/db.sql.gz {
daily
Rotate 8
nocompress
create 640 root adm
postrotate
mysqldump-u root-pPassword--all-databases >/var/backups/db.sql--single-transaction
gzip-/var/backups/db.sql 9f
endscript
}

2. One last step:

The empty file must be created, which will then be rotated. Attention if not found, logrotate will break and will generate an error.

touch/var/backups/db.sql.gz

To test the logrotate configuration you just performed, run this command:

logrotate-f/etc/logrotate.d/mysql-bkup

If you do not see errors and how to exit too early, there may be something wrong. Useful to add verbose option.

logrotate-f/etc/logrotate.d/mysql-bkup-v

3. Repeat for the tar of the sites

Do not need much imagination to alter this configuration and a tar cfz file archives sites. So enjoy the rest. Repeat task 1 and 2.

Did. There is no other.

databases

Leave a Reply

Your email address will not be published. Required fields are marked *

Un progetto da realizzare?

Start up, think tank, idee da sviluppare in sistemi e software ...
angular
Python

© ICT360. All rights reserved. Powered by ICT360.