Trying to configure logrotate for 10 daily rotation in my dump folder I have 11 rotations (mydump.sql, mydump.sql.1 ... mydump.sql.11), why?
This is my logrotate configuration file in /etc/logrotate.d/ (I'm running Ubuntu server 12.4 LTS with logrotate 3.7.8):
/home/alepac/dumps/mydump.sql {
rotate 10
daily
nomissingok
create
nocompress
nocopy
prerotate
mysqldump -u alepac -pThisIsNotMyPwd myDatabase > /home/alepac/dumps/mydump.sql
endscript
postrotate
rsync -avz --partial --delete /home/alepac/dumps/ my-remote-server.no-ip.biz:/home/alepac/db-backups/dbs/customer/ > /tmp/rsync.stdout 2> /tmp/rsync.stderr
endscript
}
For better explaination, I'm rotating the dumps of a mysql database; I'm doing the dump on prerotate, then I rotate and sync the dump dir with remote machine using rsync on postrotate. Finally the create
options makes a new zero sized dump to ensure next rotation.