I use the following /etc/crontab
code to create daily backups of my database in limit of the last 30 days:
0 8 * * * mysqldump -u root -PASSWORD --all-databases > /root/backups/mysql/db.sql
1 8 * * * zip /root/backups/mysql/db-$(date +\%F-\%T-).sql.zip /root/backups/mysql/db.sql
2 8 * * * rm /root/backups/mysql/db.sql
2 8 * * * find /root/backups/mysql/* -mtime +30 -exec rm {} \;
My problem:
I must put my password where -PASSWORD
. This way my password is exposed if by mistake I entered to change something in this file and someone near to me saw it.
Is it possible to use the script without putting the password there? Alternatively, do you know a similar syntax that won't force me to write the password there for a cronjob?