Can I run backups from the shell / cron?

If you have shell access, then running a backup from the command-line has one big advantage over running it via your website: you shouldn’t get time-outs, so the backup will not need to automatically resume, but can run through in one go.

Furthermore, from the shell you can view the progress more easily in real-time. You can also run these as cron jobs.

To kick off a backup from the shell or cron, run a PHP file in the directory of your WordPress installation that looks like this:


define('DOING_CRON', true);

If you don’t want to watch the lines being logged running past, then you can miss out the “define” line.

  • To backup just files, replace the ‘do_action’ line with:
  • To backup just the database, replace the ‘do_action’ line with:

If you want to only backup certain entities (e.g. plugins, themes, database) then replace the do_action line with:

global $updraftplus;
$backup_files = true;
$backup_database = true;
$entities_to_include = array('plugins', 'themes');
$updraftplus->boot_backup($backup_files, $backup_database, $entities_to_include);

If you wish or want to resume an already-started job, then instead of the do_action line above, use this one – but change the 12-digit hex code to the code for your job (which you can easily spot in the log file of a started job, or from the filenames in your wp-content/updraft directory):

do_action('updraft_backup_resume', 'fbb7e2919e0c', 1);

Note that on a WordPress multi-site install, you may first need to install the patch from this ticket, in order to overcome a current WordPress bug in 3.7: (or if you are on 3.6 or 3.7, get an already-patched version of the relevant WordPress file from:

Posted in: Advanced usage, Backing up