Change Updraftplus backups to use real CRON jobs

If you are hosting your own WordPress installation, you should know by now how important proper backups are  – and how annoying the wordpress ‘fake’ CRON jobs are. Updraftplus is one excellent piece of software, when it comes to WordPress backup solutions.

In this post I will show how to make Updraftplus use real CRON jobs – and at the same time possibly improve radically the backup process performance and time to execute.

updraftplusWP

Create capability to use real CRON jobs to run Updraftplus backups

Create new PHP file in your wordpress root directory (mine is named runWPbackup.php), with the following contents:

Select Code
1
2
3
4
5
<?php
define('UPDRAFTPLUS_CONSOLELOG', true);
require_once('wp-load.php');
do_action('updraft_backup_all');
?>

Next define the backup schedule in your user crontab (:~$ crontab -e), by adding for example following line:

Select Code
1
45 2  * * 6   /usr/bin/php    /var/www/html/runWPbackup.php >/dev/null 2>&1

If you are uncertain where your binary PHP is – try asking it with ‘:~$ where is php’ command. And make sure you have PHP CLI installed – you can check that with command ‘:~$ php -v’ and look for cli in the response.

This will execute the CRON on sunday (day 6 – the night between Saturday and Sunday) at 2:45am – and will not create any mail to root about the execution. In case your WordPress root directory is located somewhere else – please modify the CRONTAB line accordingly. You can also now set the Updraftplus backup schedule in plug-in settings to manual – as you have now defined the backup schedule outside of WordPress.

Improve Updraftplus backup performance

In case you think that backup creation is slow – there may be a way to have significant improvement timewise to the execution. This tip is copied with pride from the Updraftplus team support pages.

Simply put – stop using binary ZIP in backup creation – and here is how to do that.

Modify you wp-config.php with following line:

Select Code
1
2
3
4
/**
*Do not use binary ZIP with Updraftplus
*/
define('UPDRAFTPLUS_NO_BINZIP', true);

Above real CRON job change and binary zip change made my WordPress backups roughly more than 20x times faster – and also more reliable when loaded to external storage. So it might be worth trying in case you are experiencing challenges with backups in your WordPress solution.

Feedback

Juha Ketola

Juha Ketola

Author is a passionate IT enthusiast and early adopter. Packed with years of experience leading Enterprise level IT development teams within the biggest companies of Technology industry. Watches closely start-ups and new disruptive innovations in order to stay on the cutting edge. Embraces hands-on IT development and IoT.
Juha Ketola
Link to open Linkedin Profile

4 Responses to Change Updraftplus backups to use real CRON jobs

  1. Jon Allen says:

    Thanks for this. This is the best explanation of setting up a real cron job for UpdraftPlus that I’ve found. Good work!

  2. Jorge Luis says:

    gracias me ha sido de gran ayuda.
    I have a question.
    Does this cron respect the limits that are configured in Updraft or will it always run a full backup?

  3. Franco says:

    Hello, this article is very helpful.

    I would like to know if you can also add a function so that the backup is automatically uploaded to the selected cloud.

    Thank you!

Leave a Reply to Juha Ketola Cancel reply

css.php