According to this tutorial http://www.a2hosting.com/kb/getting-started-guide/backing-up-your-data/backups-on-dedicated-servers-and-vps trying to backup mysql database
I did:
1) created folders in home
directory. /home/USERNAME/backup/
2) in folder backup
created file, named backup-cron-mysql.sh
3) created content of backup-cron-mysql.sh
#!/bin/bash
db_name=dabase_name
db_user=user
db_password=password
backup_filename=$db_name-`date +%F`
mysqldump -h localhost -u $db_user -p$db_password $db_name | gzip > /home/USERNAME/dbbackup/$backup_filename.sql.gz
Made backup-cron-mysql.sh executable (Octal: 0755)
4) created folder dbbackup
. path: /home/USERNAME/dbbackup/
5) Using putty.exe
logged in and typed crontab –e
, then Enter. Latter found that cron configuration file is located in directory /var/spool/cron/
and file name is root
6) opened root
file with Notepad++ and pasted following code
45 14 * * * /bin/sh /home/USERNAME/backup/backup-cron-mysql.sh
MAILTO=my@mail.com
As result in /home/USERNAME/dbbackup/
must see some file. But see nothing (empty folder).
Please advice what need to correct, to backup mysql
Best Answer
Check the below file for the cron log output. /var/log/syslog
You can also filter the log using this command:
To configure log in your cron job:
https://askubuntu.com/questions/56683/where-is-the-cron-crontab-log