Download the PHP package phelium/mysql-backup without Composer
On this page you can find all versions of the php package phelium/mysql-backup. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package mysql-backup
MySQLBackup
- Installation
- Initialization
- Usage
- Add tables
- Exclude tables
- Set the filename
- Do not dump the table schema or the datas
- Do not add CREATE DATABASE IF NOT EXISTS
- Do not add DROP TABLE
- Do not add IF NOT EXISTS
- Compress file
- Delete file
- Auto download
- Execute the backup
- Full example
Introduction
This is a backup utility used to dump a database for backup. The backup file contains the queries to build the tables and insert the datas.
You can select some or all tables, compress the backup in ZIP or GZIP and start downloading automatically.
Installation
With Composer, add this line to your require section :
"phelium/mysql-backup": "dev-master"
Then run composer update
.
Initialization
To initialize MySQLBackup, you must provide your database information :
MySQL port default is 3306.
Usage
Add tables
By default, all tables are saved. If you want to save one or more tables, the functions addTable
or addTables
must be used:
Exclude tables
You can exclude some tables of the backup. Use excludeTables
function. The parameter must be an array containing tables name to exclude.
Set the filename
By default, the name of the generated file is "dump_{database name}_{date}". With setFilename
method, you can specify a different file name:
Do not dump the table schema or the datas
By default, the table schema (structure) and datas of each table are saved. However, it's possible not to save one or the other with setDumpStructure
and setDumpDatas
(default : true) :
Do not add CREATE DATABASE IF NOT EXISTS
By default, the CREATE DATABASE IF NOT EXISTS directive is added in top of the backup file. You can disable it with addCreateDatabaseIfNotExists
(default : true) :
Do not add DROP TABLE
By default, the DROP TABLE IF EXISTS directive is added before each CREATE TABLE. You can disable it with addDropTable
(default : true) :
Do not add IF NOT EXISTS
By default, the IF NOT EXISTS directive is added during a CREATE TABLE. You can disable it with addIfNotExists
(default : true) :
Compress file
To compress the output file, setCompress
allows to use ZIP or GZIP (default : no compression) :
Delete file
The generated file can be deleted automatically with setDelete
(default : false) :
Auto download
To download automatically the generated file, use setDownload
(default : false) :
Execute the backup
To start backing up your database, use dump
:
Full example
Here is an example to backup the blog database. Only the tables posts, comments and users are kept. Then compressed in ZIP format. The generated file is deleted from the server and the download starts automatically: