0

I'm trying to backup a single MySql Database on my website using CRON but it's not working. Command is

/usr/bin/mysqldump -uUSERNAME -pPASSWORD --databases DATABASENAME | gzip > /home/MYSITE/forumbackup/backup.$(date +"%d_%m_%Y_%H_%M_%S").sql.gz

There is no error message in log files or the default email account. I know the location of mysqldump is correct as I checked with my hoster. I'm assuming gzip can be called as is.

any advice?

Swisstone
  • 6,357
  • 7
  • 21
  • 32
Neil
  • 1
  • 1
    What is the problem you are having? – Michael Hampton Jan 06 '21 at 10:24
  • How did you determine that it's "not working"? – Gerald Schneider Jan 06 '21 at 10:24
  • What is the user the cronjob is executing as? – Tero Kilkanen Jan 06 '21 at 10:42
  • There is no backup file in the directory specified, The user being used was used before I migrated hosts and was working previously with a PHP script. It is a DB user with rights. – Neil Jan 06 '21 at 11:41
  • 2
    Does this answer your question? [Why is my crontab not working, and how can I troubleshoot it?](https://serverfault.com/questions/449651/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it) – Bob Jan 06 '21 at 12:00
  • 1
    Note that among other the `%` percent sign usually has special meaning in cron tab files and may need extra escapes – Bob Jan 06 '21 at 12:02
  • I thought I had solved this. I escaped the % signs in the date statement \% instead of just %. The mysqdump file is created in the correct directory but is only 20kb and it should be about 545,000Kb – Neil Jan 07 '21 at 10:15
  • May be a password issue, db user account was created on new host, I have reset the password and will try again. – Neil Jan 07 '21 at 10:36
  • Tat all worked, problem resolved. – Neil Jan 08 '21 at 10:07

0 Answers0