I deployed MariaDB with Docker in Unraid, I know that the best choice is solving errors in the log. But I still want to rotate the error log.
I created the following configuration file native to Unraid(/etc/logrotate.d/mariadb):
/mnt/user/appdata/mariadb/databases/mariadb.err {
su nobody users
missingok
create 660 nobody users
notifempty
daily
minsize 1M
maxsize 100M
rotate 30
dateext
dateformat .%Y-%m-%d-%H-%M-%S
compress
delaycompress
sharedscripts
olddir ../archive/
createolddir 770 nobody users
postrotate
# just if mysqld is really running
if docker exec mariadb test -x /usr/bin/mysqladmin && \
/docker exec mariadb usr/bin/mysqladmin ping &>/dev/null
then
/docker exec mariadb usr/bin/mysqladmin --local flush-error-log \
flush-engine-log flush-general-log flush-slow-log
fi
endscript
}
After executing logrotate --force /etc/logrotate.d/mariadb
, everything seemed OK only that the new logs were still appended to the archived file, the mariadb.err file was empty.