WireDatabaseBackup::backup() method

Perform a database export/dump

Usage

// basic usage
$string = $backup->backup();

// usage with all arguments
$string = $backup->backup(array $options = []);

Arguments

NameType(s)Description
options (optional)array

Options to modify default behavior:

  • filename (string): filename for backup: default is to make a dated filename, but this can also be used (basename only, no path)
  • description (string): optional description of this backup
  • tables (array): if specified, export will only include these tables
  • user (string): username to associate with the backup file (string), optional
  • excludeTables (array): exclude creating or inserting into these tables
  • excludeCreateTables (array): exclude creating these tables, but still export data
  • excludeExportTables (array): exclude exporting data, but still create tables
  • whereSQL (array): SQL conditions for export of individual tables [table => [SQL conditions]]. The table portion (index) may also be a full PCRE regexp, must start with / to be recognized as regex.
  • maxSeconds (int): max number of seconds allowed for execution (default=1200)
  • allowDrop (bool): use DROP TABLES statements before CREATE TABLE statements? (default=true)
  • allowUpdate (bool): use UPDATE ON DUPLICATE KEY so that INSERT statements can UPDATE when rows already present (all tables). (default=false)
  • allowUpdateTables (array): table names that will use UPDATE ON DUPLICATE KEY (does NOT require allowUpdate=true)
  • findReplace (array): find and replace in row data during backup. Example: ['databass' => 'database']
  • findReplaceCreateTable (array): find and replace in create table statements Example: ['DEFAULT CHARSET=latin1;' => 'DEFAULT CHARSET=utf8;']
  • extraSQL (array): additional SQL queries to append at the bottom. Example: ['UPDATE pages SET created=NOW()']

Return value

string

Full path and filename of database export file, or false on failure.

Exceptions

Method can throw exceptions on error:

  • \Exception - on fatal error

See Also


$backup methods and properties

API reference based on ProcessWire core version 3.0.155

Twitter updates

  • This post covers a few of the bigger updates in ProcessWire 3.0.154+3.0.155. This includes new live replacement of text in core and modules, a new method for creating canonical URLs, and some major upgrades to our input->urlSegment() method! More
    24 April 2020
  • A brief look at what's new in ProcessWire 3.0.154 in this forum post: More
    17 April 2020
  • This week we’ve got a few new and interesting core updates in progress, though none quite ready to release just yet. So rather than releasing version 3.0.154 today, I thought we'd instead take a brief look at what’s coming over the next few weeks… More
    3 April 2020

Latest news

  • ProcessWire Weekly #312
    In the 312th issue of ProcessWire Weekly we're going to check out the latest core updates, a couple of new third party modules, and a brand new site of the week. Read on!
    Weekly.pw / 2 May 2020
  • ProcessWire 3.0.154 and 3.0.155 core updates
    This post covers a few of the bigger updates in ProcessWire 3.0.154 and 3.0.155 on the dev branch. This includes a new function for live replacement of text in core and modules, a new method for creating canonical URLs, and some major upgrades to our $input->urlSegment() method that I think you’ll like!
    Blog / 24 April 2020
  • Subscribe to weekly ProcessWire news

“We chose ProcessWire because of its excellent architecture, modular extensibility and the internal API. The CMS offers the necessary flexibility and performance for such a complex website like superbude.de. ProcessWire offers options that are only available for larger systems, such as Drupal, and allows a much slimmer development process.” —xport communication GmbH