MySQL Automatic Databases Backup with Cron and mysqldump

To have all the MySQL databases Updated at the same time make a Cronjob with the following Content:

0 0 * * * mysqldump -u root -pPASSWORD --all-databases | gzip > /path/To/database_$(date +%m-%d-%Y).sql.gz 

You can view this Command like divided in Two parts:

  1. The Frequence of Crontab Command Execution

    0 0 * * *
    •    0 for minute
    •    A 0 for hour
    •    An * for Every Day
    •    An * for Every Month
    •    An * for Every Day of the Week
  2. The Command to be Executed

    mysqldump -u root -pPASSWORD --all-databases | gzip > /path/To/database_$(date +%m-%d-%Y).sql.gz

    A pipe with the "mysqldump" Output passed for Compression to "gzip"

    The "date +%m-%d-%Y" Command add a Timestamp of the Form Month-Day-Year


Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer