mysql database backup script in mint

mint is not turned on by default cron logging 

1. Modify rsyslog 

sudo vim /etc/rsyslog.d/50-default.conf 

cron.* /var/log/cron.log 

# The cron front uncommented 

2. Restart rsyslog 

sudo service rsyslog restart 

3. Check the crontab log 

sudo tail -f /var/log/cron.log

The default cron will send mail to operating results of the task such as sending an error message to the user's mailbox system, and information specific script output does not appear in the log, so we can specify what log output path of each task:

#0 2 * * * db_backup task; >> /var/log/db_backup.log 2>&1

*/1 * * * *  /bak/bkmysql.sh

 
 

 

 

cat bkmysql.sh
#!/bin/bash
User="root"
Password="admin"
Database="test"
Dir="/bak/mysql"
Date=`date +%Y%m%d_%H%M%S`

sudo mysqldump -u$User -p$Password $Database|gzip >$Dir/$Database.dump_$Date.sql.gz

 

 

 
 

Guess you like

Origin www.cnblogs.com/minipython/p/11330568.html