Constants

IDLE

IDLE = 0

APPEND

APPEND = 1

CREATE

CREATE = 2

Properties

$excludeZip

$excludeZip : boolean

Whether to exclude zip archives.

Type

boolean — Set true to exclude ZIP archives from the backup.

$archive

$archive : resource

Backup archive file.

Type

resource — Backup file.

$archivePath

$archivePath : string

Backup archive file path.

Type

string — Backup file path.

$archiveSize

$archiveSize : float

Backup archive file size.

Type

float — Backup file size.

$lastRun

$lastRun : string

Last time a backup has been run.

Type

string — Last backup run.

$debug

$debug : boolean

Enable debug mode.

Type

boolean — Set try to enable debugging.

$chunk

$chunk : string

Chunk of the backup.

Type

string — Backup chunk.

$chunkSize

$chunkSize : integer

Backup chunk size.

Type

integer — Backup chunk size.

$backup

$backup : object

MainWP_Backup class instance.

Type

object — MainWP_Backup class

$type

$type : string

Backup archive type.

Type

string — Archive type.

$pidFile

$pidFile : resource

Backup PID file.

Type

resource — PID file.

$pidContent

$pidContent : string

Backup PID file content.

Type

string — PID file content.

$pidUpdated

$pidUpdated : string

Time of the last PID file update.

Type

string — Last PID file update.

$mode

$mode : integer

Arvive mode, IDLE, APPEND or CREATE.

Type

integer — Arvive mode.

$logHandle

$logHandle : boolean

Enable logging.

Type

boolean — Set true to log records.

$block

$block : array

Block of the backup content.

Type

array — Block of content.

$tempContent

$tempContent : string

Temprary backup content.

Type

string — Temprary content.

$gcCnt

$gcCnt : integer

Garbage collection count.

Type

integer — Garbage collection count.

$cnt

$cnt : integer

Count number.

Type

integer — Count number.

Methods

__construct()

__construct(object  $backup, string  $type = 'tar', boolean  $pidFile = false) 

Tar_Archiver constructor.

Run any time class is called.

Parameters

object $backup

MainWP_Backup class instance.

string $type

Backup arvhive type.

boolean $pidFile

Request PID file or not.

get_extension()

get_extension() : string

Get backup archive file extension, .tar.bz2, .tar.gz or .tar.

Returns

string —

Aarchive file extension, .tar.bz2, .tar.gz or .tar.

zip_file()

zip_file(array  $files, string  $archive) : boolean

Create ZIP file.

Parameters

array $files

Files to zip.

string $archive

Type of archive to create.

Returns

boolean —

Return false on failure, true on success.

update_pid_file()

update_pid_file() : boolean

Update backup archive PID file.

Returns

boolean —

Return false on failure, true on success.

create_full_backup()

create_full_backup(string  $filepath, array  $excludes, boolean  $addConfig, boolean  $includeCoreFiles, boolean  $excludezip, boolean  $excludenonwp, boolean  $append = false) : boolean

Create full backup.

Parameters

string $filepath

Backup file path.

array $excludes

Files to exclude from the backup.

boolean $addConfig

Add config file to backup.

boolean $includeCoreFiles

Include WordPress core files.

boolean $excludezip

Exclude zip files from the backup.

boolean $excludenonwp

Exclude non-WordPress directories in site root.

boolean $append

Append to backup file name.

Throws

\Exception

Returns

boolean —

Return false on failure, true on success.

add_dir()

add_dir(string  $path, array  $excludes) 

Add directory to the backup archive file.

Parameters

string $path

File path.

array $excludes

List of file to exclude from the backup.

log()

log(string  $text) 

Log messages to the backup error log.

Parameters

string $text

Log message.

create()

create(string  $filepath) 

Create backup archive file.

Parameters

string $filepath

File location path.

append()

append(string  $filepath) 

Append to the backup archive file.

Parameters

string $filepath

File location path.

is_open()

is_open() : boolean

Verify if the backup archive file is open.

Returns

boolean —

True if open, if not, false.

prepare_append()

prepare_append(string  $filepath) 

Prepare the append process.

Parameters

string $filepath

File location path.

Throws

\Exception

Error message.

read()

read(string  $filepath) 

Read the backup archive file.

Parameters

string $filepath

File location path.

close()

close(boolean  $closeLog = true) 

Close the backup archive file.

Parameters

boolean $closeLog

Log this action if set true.

get_from_name()

get_from_name(string  $entryName) : string

Get File content retrived by name.

Parameters

string $entryName

Entry name.

Returns

string —

File content.

file_exists()

file_exists(string  $entryName) : boolean

Check if the file exists.

Parameters

string $entryName

Entry name.

Returns

boolean —

Return tru if the file exists, false if it doesn't.

extract_to()

extract_to(string  $to) : null

Extract backup archive file to a location.

Parameters

string $to

Desired location to extract file.

Returns

null

is_valid_block()

is_valid_block(array  $block) : boolean

Check if block is valid.

Parameters

array $block

Block of the backup file content.

Returns

boolean —

Return true if it's valid block, false if not.

create_pid_file()

create_pid_file(resource  $file) : boolean

Create backup archive PID file.

Parameters

resource $file

Backup archive PID file.

Returns

boolean —

Return false on failure, true on success.

complete_pid_file()

complete_pid_file() : boolean

Complete backup archive PID file.

Returns

boolean —

Return false on failure, true on success.

include_core_files()

include_core_files(array  $nodes) 

Include WordPress core file.

Parameters

array $nodes

Default nodes.

add_data()

add_data(\MainWP\Child\arary  $data) 

Add data to the backup archive file.

Parameters

\MainWP\Child\arary $data

Data to add to the backup archive file.

Throws

\Exception

Error message.

write_chunk()

write_chunk() 

Write backup chunk.

Throws

\Exception

Error message.

add_empty_dir()

add_empty_dir(string  $path, string  $entryName) 

Fire off the add_empty_directory() function.

Parameters

string $path

File path.

string $entryName

Entry name.

add_empty_directory()

add_empty_directory(string  $entryName, integer  $mode, integer  $uid, integer  $gid, string  $mtime) 

Add empty directory to the backup archive file.

Parameters

string $entryName

Entry name.

integer $mode

Inode protection mode.

integer $uid

Userid of the file owner.

integer $gid

Groupid of the file owner .

string $mtime

Time of last modification of the file.

add_file()

add_file(string  $path, string  $entryName) : boolean

Add file to the backup archive file.

Parameters

string $path

File path.

string $entryName

Entry name.

Throws

\Exception

Returns

boolean —

Return false on failure, true on success.

add_file_from_string()

add_file_from_string(string  $entryName, string  $content) : boolean

Add file from a string.

Parameters

string $entryName

Entry name.

string $content

Entry content.

Returns

boolean —

Return false on failure, true on success.

check_before_append()

check_before_append(string  $entryName) : array

Check before append.

Parameters

string $entryName

Entry name.

Returns

array —

Return function output.

is_next_file()

is_next_file(string  $entryName) : array|boolean

Is next file.

Parameters

string $entryName

Entry name.

Throws

\Exception

Error message.

Returns

array|boolean —

If true,skip file, if false or number, nothing to read, will continue with current file.

read_next_bytes()

read_next_bytes(resource  $file) : array|boolean

Read next bytes.

Parameters

resource $file

File to process.

Returns

array|boolean —

Number of bytes or false on failure.