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.148

Twitter updates

  • Weekly update for Jan 10, 2020—front-end file uploads in LoginRegisterPro with InputfieldFrontendFile module: More
    10 January 2020
  • If you haven't seen it yet, be sure to check out this great infographic by @teppokoivula in ProcessWire Weekly #294— How ProcessWire professionals work—the results of our recent weekly polls summarised: weekly.pw/issue/294/#how…
    3 January 2020
  • Today we have a new master version released, 3.0.148! There are 25 new versions worth of upgrades, fixes and optimizations in this new master version, relative to the previous. In this post we take a closer look at what’s new, how to upgrade, & more— More
    3 January 2020

Latest news

  • ProcessWire Weekly #298
    In the 298th issue of ProcessWire Weekly we're going to take a quick look at the latest core updates, introduce the PWGeeks project, and highlight some recently released ProcessWire content. Read on!
    Weekly.pw / 25 January 2020
  • ProcessWire 3.0.148 new master
    Today we have a new master version released, version 3.0.148! The last master version was 3.0.123, so there are 25 new versions worth of upgrades, fixes and optimizations in this new master version, relative to the previous. In this post we’ll take a closer look at what’s new, how to upgrade, and more.
    Blog / 3 January 2020
  • Subscribe to weekly ProcessWire news

I just love the easy and intuitive ProcessWire API. ProcessWire rocks!” —Jens Martsch, Web developer