Automated MySQL backup on Ubuntu with cron

If you would like to take periodic backups of your MySQL database, you can do it easily with cron:

open crontab file:
nano /etc/crontab

add the following line at the end of file:
*/15 * * * *       root    /usr/bin/mysqldump -u<mysql_user> -p<mysql_password> <database_name> > <directory-to-save>-<file-prefix>`/bin/date +\%Y\%m\%d-\%H\%m`.sql
(the above line orders cron to get your backup every 15 minutes)


 

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
8 + 10 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.