ZenphotoCMS 1.6.2

backupRestore
in package

Class for creating and restoring database backups.

Note that this does not create a standalone SQL backupg but data stored as serialized arrays that the restoreBackup() method turns into SQL statements. For an actual SQL update use tools like phpmyadmin or the commandline "mysqldump".

Basic usage:

$backuprestore = new backupRestore(); // The constructor does not have any parameteres. Options are set via the class property $backuprestore->compression_handler = 'no';

$backuprestore->createBackup(); or $backuprestore->restoreBackup($backupfile); // file name without path and suffix

Tags
since
1.6.2

Moved from inline procedural functions to separate class

Table of Contents

Properties

$autobackup  : bool
Default false. Enables autobackup mode used for running via zp crons
$backupfile  : mixed
$buffer  : mixed
$compression_handler  : string
Default "no" for no compression. This is set via createBackup() and restoreBackup() internally depending on the compression level < 1 and bzip or gzio depending on system availability
$compression_level  : int
Default 0. Any value larger larger than one enables compression
$db_prefix  : mixed
$db_prefix_length  : mixed
$debuglog_messages  : mixed
$errors  : mixed
$file_version  : mixed
$header  : mixed
$messages  : mixed
$missing_element  : mixed
$missing_table  : mixed
$record_separator  : mixed
$respond_counter  : mixed
$signature  : mixed
$table_separator  : mixed

Methods

__construct()  : mixed
Set options via properties before creating or restoring backups
compressRow()  : type
Compresses a row if a compression level is set to 1 or higher
createBackup()  : mixed
Creates a database backup
decompress()  : type
Decompresses field or row data which is set within restoreBackup()
extendExecution()  : mixed
"Extends" the PHP script execution by defining a time limit and echoing empty content
fillBuffer()  : bool
Fills the buffer on reading data from the file handle
getRow()  : bool
Gets a row from the file handle resource
printMessages()  : mixed
Prints messages like success or error notices generated by creating or restoring a backup
restoreBackup()  : mixed
Restores a backup
writeHeader()  : int|false
Writes header information to the first lines of a backup file

Properties

$autobackup

Default false. Enables autobackup mode used for running via zp crons

public bool $autobackup = \false

$compression_handler

Default "no" for no compression. This is set via createBackup() and restoreBackup() internally depending on the compression level < 1 and bzip or gzio depending on system availability

public string $compression_handler = 'no'

$compression_level

Default 0. Any value larger larger than one enables compression

public int $compression_level = \false

Methods

__construct()

Set options via properties before creating or restoring backups

public __construct() : mixed

compressRow()

Compresses a row if a compression level is set to 1 or higher

public compressRow(sting $str, int $lvl) : type
Parameters
$str : sting

Data to compress

$lvl : int

Block size during compression

Return values
type

decompress()

Decompresses field or row data which is set within restoreBackup()

public decompress(sting $str) : type
Parameters
$str : sting

Data to compress

Return values
type

extendExecution()

"Extends" the PHP script execution by defining a time limit and echoing empty content

public extendExecution() : mixed

fillBuffer()

Fills the buffer on reading data from the file handle

public fillBuffer(resource $handle) : bool
Parameters
$handle : resource

Backup file resource

Return values
bool

getRow()

Gets a row from the file handle resource

public getRow(resource $handle) : bool
Parameters
$handle : resource

Backup file resource

Return values
bool

printMessages()

Prints messages like success or error notices generated by creating or restoring a backup

public printMessages() : mixed

restoreBackup()

Restores a backup

public restoreBackup(string $backupfile) : mixed
Parameters
$backupfile : string

The file name without path and suffix to restore from

writeHeader()

Writes header information to the first lines of a backup file

public writeHeader(string $type, string $value, resource $handle) : int|false
Parameters
$type : string

Header type "file_version" or "compression_handler"

$value : string

Header type value

$handle : resource

Backup file resource

Return values
int|false

        
On this page

Search results