2

I have setup of Database daily backup every night at 12:30am, through Admin's System>Configuration>Advanced>System>Scheduled Backup Settings.

Magento backs up the data base. But it creates 4 of the same backup files, instead of just one. I started this two nights ago, and it has done it consistently for the past 2 nights. 4 database backups every night at around 12:30, 12:31, 12:32 and 12:33!

How can I stop that from happening and make it to create one back up file?

System>Configuration>Advanced>System>Cron (Scheduled Tasks)

Generate Schedules Every: 15
Schedule Ahead for: 20
Missed if Not Run Within: 15
History Cleanup Every: 10
Success History Lifetime: 60
Failure History Lifetime: 600

The following is the cron i have on the server:

* * * * * wget -O /dev/null -q http://domainDOTcom/path/to/magento/cron.php

1

Couple of things here.

  1. Never use the inbuilt backup tool. Its flawed in far too many ways to be useful. Instead, use conventional server tools to dump the DB and backup the files.

    Eg. Some Magento specific tools for DB dumping

    Or generic tools for MySQL dumping

    And for file backups, use things like rsync or tar to generate backups,

    Eg.

    • Using tar

      tar cvfz /path/to/backup.tgz /path/to/public_html \
        --exclude='/var/log' \
        --exclude='/var/session' \
        --exclude='/var/cache' \
        --exclude='/var/backup' \
        --exclude='/var/report' \
        --exclude='/media/catalog/product/cache'
      
    • Using rsync

      rsync -vPa /path/to/public_html/ /path/to/backup_html/  \
        --exclude='/var/log' \
        --exclude='/var/session' \
        --exclude='/var/cache' \
        --exclude='/var/backup' \
        --exclude='/var/report' \
        --exclude='/media/catalog/product/cache'
      
  2. You should never execute your cron via wget - you should be using the cron.sh wrapper to execute it,

    * * * * * /bin/bash /path/to/public_html/cron.sh
    
|improve this answer|||||
  • I changed the cron from * * * * * wget -O /dev/null -q http://domainDOTcom/path/to/magento/cron.ph' to * * * * * /bin/bash /path/to/public_html/cron.sh. What is difference between wget method and cron.sh? They both seem to work. Also, any idea why System>Configuration>Advanced>System>Scheduled Backup Settings is making 4 database backups? – user2774042 Jul 2 '15 at 20:30
  • There's loads of reasons. 1. No job control when run via wget, which means your cron will overlap and run multiple times. 2. Security, crons shouldn't be run in the context of a web server. 3. Newer versions of Magento require arguments to be passed to cron.php to dictate the type of cron being run. – Ben Lessani - Sonassi Jul 3 '15 at 12:59
  • Regarding backups. Do not use the built in tool - it is broken. – Ben Lessani - Sonassi Jul 3 '15 at 12:59
  • 1
    There's loads of reasons. 1. No job control when run via wget, which means your cron will overlap and run multiple times. 2. Security, crons shouldn't be run in the context of a web server. 3. Newer versions of Magento require arguments to be passed to cron.php to dictate the type of cron being run. – Ben Lessani - Sonassi Jul 8 '15 at 18:10
  • 1
    Remember that Magento upgrades reset file permissions. So its best using /bin/bash /path/to/cron.sh - which mitigates the requirement for executable permissions :) – Ben Lessani - Sonassi Jul 9 '15 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.