Question

mysqlsumb

Posted July 8, 2013 7.3k views
Hallo! How can i via crontab add a mysqldumb that runs every day at 21:00 CET (danish time) and put it in /home/xxx

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
Submit an Answer
16 answers
Set your droplet's timezone to CET:

sudo dpkg-reconfigure tzdata

Run "crontab -e" to edit your cronjobs (or "EDITOR=nano crontab -e" if you want to use nano), and append the following line:

0 21 * * * /bin/bash /home/xxx/script.sh
can i do 0 21 * * * /usr/bin/mysqldump /home/xxx/
You can type out the command there, yes.
I have made a mysqldump.sh (and chmod +x the file) script with the following content :

#!/bin/bash

suffix=$(date +%w%a)

rm /home/backup/xxx/$suffix.sql.gz
mysqldump -h localhost -u root -pxxxxxx xxxx | gzip > /home/backup/xxx/$suffix.sql.gz

and entered this in crontab : 0 21 * * * /bin/bash /home/xxx/mysqldump.sh

will that work?
looks like itsworking, did sh mysqldump.sh :)
Another thing can i get cron to email me when the backup is completet?

like backup is done the cron sents a mail with "Backup Completed" ?
Yes, append this to mysqldump.sh:

echo "MySQL backup" | mail -s "MySQL backup" your@email.com
I tried this : * * * * * /bin/echo "foobar" >> /home/backup/testfile.txt echo "Mysql Backup Cpmpleted | mail -s "Backup Completed" firesecret@gmail.com

But get this error in my mail : /bin/sh: 1: Syntax error: Unterminated quoted string
Add it to the script itself not the cronjob.
missed a " :D but there is no body text (content) only subject does contain what i want
Previous 1 2 Next