Download the PHP package coderatio/simple-backup without Composer
On this page you can find all versions of the php package coderatio/simple-backup. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download coderatio/simple-backup
More information about coderatio/simple-backup
Files in coderatio/simple-backup
Package simple-backup
Short Description A simple mysql database backup library for php.
License MIT
Informations about the package simple-backup
Simple-backup
A simple mysql database backup library for php. This library helps you backup your mysql database to a directory in your project or download it to your machine.
The library also allows you import or restore a database without stress. Follow the instructions below to get started.
Installation
Open your terminal or command prompt and type the below command:
New in version 1.0.1
- You can now chain static
::start()
on `SimpleBackup class. - This version includes fluent chaining of database settings.
- Added
->includeOnly(array $tables)
which allows you to export data for only tables mentioned in$tables
variable. - Added
->excludeOnly(array $tables)
which removes the inclussion of tables mentioned in$tables
variable during export.
(v1.0.1) Exporting specific tables only
(v1.0.1) Excluding specific tables only
Exporting
The export can be done in two ways.
- Store in a directory
- Download to your machine
1-- Store in a directory
To store the export in a directory, do this:
To get the stored file name, you can echo it out like this:
You can also get the reponse by doing this:
2-- Download
To download the export to your machine, do this:
If $file_name isn't provided, a random name will be generated for the download.
Adding where clauses to tables
To add where clauses as you would do on SQL, you can do this before exporting:
Note: $tables
variable must be an associative array e.g
Setting rows limit on tables
To limit how many rows to be included in your backup for a table, do this before exporting:
Note: Just like adding where clauses, the $tables
variable here must be an associative array. e.g
Importing
This package makes importing or restoring your mysql database easy. To import your database, do this:
Note: You can provide sql statements as the parameter. You may also overwrite the database configuration by passing it as second parameter to the importFrom(). e.g importFrom(pathtosql_file, array $db_config);
.
Todo
- Add a scheduler method to use with cron
- Store backup in Dropbox, Google Drive.
- Send backup to emails
Contribution
To contribute to this project, send a pull request or find me on Twitter.
License
This project is licenced with the MIT license.