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.

/var/backups/db.sql.gz {
Rotate 8
create 640 root adm
mysqldump-u root-pPassword--all-databases >/var/backups/db.sql--single-transaction
gzip-/var/backups/db.sql 9f

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.


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


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


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.


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 ...

© ICT360. All rights reserved. Powered by ICT360.