To add a logrotate script, you can create a file, and add it to /etc/logrotate.d/
This is the file script content:
/yourfolder/name-name-bak-*.sql {
weekly
missingok
rotate 14
compress
delaycompress
notifempty
create 640 root root
}
In this case:
weekly
it will be run once per week
missingok
If the log file is missing, go on to the next one without issu-
ing an error message
rotate 14
Log files are rotated 14 times before being removed or
mailed to the address specified in a mail directive. If count is
0, old versions are removed rather then rotated.
compress
Old versions of log files are compressed with gzip by default.
delaycompress
Postpone compression of the previous log file to the next rota-
tion cycle. This has only effect when used in combination with
compress. It can be used when some program can not be told to
close its logfile and thus might continue writing to the previ-
ous log file for some time.
notifempty
Do not rotate the log if it is empty
create 640 root root
Set user group and rights to the rotated files
more information on the man page : http://www.linuxcommand.org/man_pages/logrotate8.html
To launch manually (or test) your script, you can use the following command:
logrotate --force /etc/logrotate.d/yourfilename