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
[email protected]
As result in /home/USERNAME/dbbackup/
must see some file. But see nothing (empty folder).
Please advice what need to correct, to backup mysql
crontab
file manually, so cron probably doesn't know you've made any changes. It's always best to use thecrontab
command, because that sends a signal to cron to re-read the config files. Try usingcrontab
to make a trivial change in the file, then see if your backups run.