• Resolved markussss

    (@markussss)


    Hi there,

    I wonder how the scheduled automatic backups work with Updraft when wp-cron is disabled.

    define('DISABLE_WP_CRON', true);

    WP_CRON is disabled for a reason, as I am using Updraft on a development site which is password protected via .htaccess

    Hence, I think WP_CRON won’t be triggered anyway as there won’t be any visitors on the site.

    I researched and found two approaches, I am not sure which one is valid or to prefer

    First
    Add a PHP script to the root folder with a minimum of 705 permission and run the script e.g. runupdraftbackup.php via server cron on a daily basis

    <?php

    define(‘UPDRAFTPLUS_CONSOLELOG’, true);
    define(‘DOING_CRON’, true);
    require_once(‘wp-load.php’);
    do_action(‘updraft_backupnow_backup_all’, array(‘nocloud’ => 1));
    ?>

    Second
    Just run wp-cron via server cron by adding this line to the server cron.
    I am not sure if I fully understand it, it sounds to me as every task that is scheduled within wp-cron will be run this way

    wget -q -O - https://dev.mysite.com/wp-cron.php?doing_wp_cron >/dev/null 2>&1

    Thanks in advance for your help

    best regards
    Markus

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter markussss

    (@markussss)

    Plugin Contributor DNutbourne

    (@dnutbourne)

    Hi,

    Apologies for the delay in replying.

    Either of these approaches would work, but have slightly different results.

    The first will only run the UpdraftPlus backup task, and does not require the schedule to be set in the UpdraftPlus settings.
    The second will ensure that all scheduled tasks will be run.

    Thread Starter markussss

    (@markussss)

    Thanks, perhaps that solves a lot of other questions for me now. Then I can just use the normal scheduler via cron and do not need the provided PHP script.

    One related follow up that perhaps is also valid for Updraft.

    Many plugins give notice when wp-cron is disabled. I think (and please correct me if I am wrong) the plugin cannot know about the server cron job.

    So wouldn’t it be best to keep wp-cron enabled. It shouldn’t harm performance as many stated. And it would not confuse plugins
    define('DISABLE_WP_CRON', false);

    Or will there be some conflicts when wp-cron is enabled AND server cron triggers wp-cron as well (like I stated in “Second” in my initial post)

    Thanks so much for sharing. If I get that right, I can also share this information as I think there is a lot of misinformation out there about cron and wp-cron.

    best regards
    Markus

    Plugin Contributor Prashant Baldha

    (@pmbaldha)

    I believe the WP site would improve performance with the second solution (corn run with wget).

    Thread Starter markussss

    (@markussss)

    Performance aside (that’s another topic, and there is no verdict on that topic), when there is only a server cron, isn’t Updraft giving notice that it can’t run the automatic backups?

    If it is a server cron, how should Updraft Plugin know about it. The server cron is defined outside of WordPress.

    If there is an Updraft notice that informs about the disabled wp-cron (because of the fact that there is a server cron), then this would be a false-alarm from Updraft.

    So wouldn’t it be best to keep wp-cron enabled. It shouldn’t harm performance as many stated. And it would not confuse plugins
    define(‘DISABLE_WP_CRON’, false);

    Or will there be some conflicts when wp-cron is enabled AND server cron triggers wp-cron as well (like I stated in “Second” in my initial post)

    Thread Starter markussss

    (@markussss)

    See the notice here, cron job for Updraft is enabled by running the PHP script via cron job. I see the backups do run on a daily basis. However, it gives me this notifications and also tells me the next update is due some date in the past

    2022-10-23_21-21-57.png

    Plugin Contributor Prashant Baldha

    (@pmbaldha)

    You can hide the cron-related notice by adding the below code line in the wp-config.php file:

    
    define('UPDRAFTPLUS_DISABLE_WP_CRON_NOTICE', true);
    
    Thread Starter markussss

    (@markussss)

    Thanks for providing that ‘snippet’ Prashant!

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Automatic backups on password protected site with disabled wp-cron’ is closed to new replies.