Backup MySQL Database from Cron

Description

Backup a database from cron. Add the following to the cron tab.

Snippet

date=`/bin/date "+\%Y-\%m-\%d-\%H-\%M-\%S"` ; cd /home/[USERNAME]/public_html; mysqldump -u [DATABASE USERNAME] -p[PASSWORD] [DATABASE NAME] > /home/[USERNAME]/backups/[DATABASE NAME]backup_$date.sql ; gzip /home/[USERNAME]/backups/[DATABASE NAME]backup_$date.sql

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options