PHPackages                             julio101290/mysql-backup - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. julio101290/mysql-backup

ActiveLibrary[Database &amp; ORM](/categories/database)

julio101290/mysql-backup
========================

A PHP library for backing up and restoring MySQL databases

1.0.5(1y ago)0711MITPHPPHP ^8.0

Since May 10Pushed 1y agoCompare

[ Source](https://github.com/julio101290/mysql-backup)[ Packagist](https://packagist.org/packages/julio101290/mysql-backup)[ RSS](/packages/julio101290-mysql-backup/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (6)Used By (1)

MySQL Backup &amp; Restore Library
==================================

[](#mysql-backup--restore-library)

[![Latest Stable Version](https://camo.githubusercontent.com/035846ddcd8733e4a643d41a7e2e19b95bd0698d550c10a12b127baa0b07a9f9/68747470733a2f2f706f7365722e6f6b76706e2e6f72672f6a756c696f3130313239302f6d7973716c2d6261636b75702f762f737461626c65)](https://packagist.org/packages/julio101290/mysql-backup) [![Total Downloads](https://camo.githubusercontent.com/00a4991bf3fd62aa831f59cee14b8b9ebca468dff7382cf4031f9e95e0d70f6c/68747470733a2f2f706f7365722e6f6b76706e2e6f72672f6a756c696f3130313239302f6d7973716c2d6261636b75702f646f776e6c6f616473)](https://packagist.org/packages/julio101290/mysql-backup) [![Latest Unstable Version](https://camo.githubusercontent.com/96259528d2b26933ff487214e37ca94b73c6c56f341b91c1b5a8e4a861308957/68747470733a2f2f706f7365722e6f6b76706e2e6f72672f6a756c696f3130313239302f6d7973716c2d6261636b75702f762f756e737461626c65)](https://packagist.org/packages/julio101290/mysql-backup) [![License](https://camo.githubusercontent.com/be6c472e23ff90475bc4de4a017956ca1afcfc8b76b352f7d9a644fb6828143a/68747470733a2f2f706f7365722e6f6b76706e2e6f72672f6a756c696f3130313239302f6d7973716c2d6261636b75702f6c6963656e7365)](https://packagist.org/packages/julio101290/mysql-backup)

An update with the necessary configuration settings for sending emails via PHPMailer is coming soon. Stay tuned.

 [ ![Logo](https://camo.githubusercontent.com/5d74a2fccc1ab97a3f0bf82546513a25280f867c1624f5a7954e867fb283d4e4/68747470733a2f2f7777772e6d7973716c2e636f6d2f636f6d6d6f6e2f6c6f676f732f6c6f676f2d6d7973716c2d313730783131352e706e67) ](https://github.com/ramazancetinkaya/mysql-backup)

### MySQL Backup &amp; Restore Library

[](#mysql-backup--restore-library-1)

 A powerful and modern PHP library for backing up and restoring MySQL databases using PDO.
 [**Explore the docs »**](https://github.com/ramazancetinkaya/mysql-backup/blob/main/README.md)

 [Report a Bug](https://github.com/ramazancetinkaya/mysql-backup/issues) · [New Pull Request](https://github.com/ramazancetinkaya/mysql-backup/pulls)

🌟 Star this Repository!
-----------------------

[](#-star-this-repository)

If you find the MySQL Backup &amp; Restore library helpful or interesting, consider giving it a star! ⭐️

Your star helps us grow and motivates us to continue improving the library. It also makes it easier for others to discover and benefit from this project.

### How to Star?

[](#how-to-star)

1. **Login to Your GitHub Account:** You need to have a GitHub account.
2. **Visit the Repository:** Go to the [MySQL Backup &amp; Restore Repository](https://github.com/ramazancetinkaya/mysql-backup).
3. **Click the Star Button:** On the top-right corner of the page, you'll find a "Star" button. Click on it!

That's it! Thank you for your support! 🚀

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
- [About the Project](#about-the-project)
- [Screenshot](#screenshot)
- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Disclaimer](#disclaimer)
- [Contributing](#contributing)
- [Authors](#authors)
- [License](#license)
- [Copyright](#copyright)

Introduction
------------

[](#introduction)

This library is meticulously crafted to cater to a wide spectrum of users, ranging from novices venturing into the field to seasoned developers seeking seamless integration and robust functionality.

About the Project
-----------------

[](#about-the-project)

The MySQL Backup &amp; Restore Library furnishes comprehensive functionalities tailored for the seamless backup and restoration of MySQL databases through PHP. Leveraging this library, developers can effectively safeguard vital data housed within MySQL databases, ensuring robust data integrity and facilitating swift recovery in the event of data loss or system failures.

### Screenshot

[](#screenshot)

[![Screenshot](mysql-backup.png)](mysql-backup.png)

Features
--------

[](#features)

- Backup entire MySQL databases or specific tables.
- Restore databases from backup files.
- Generate SQL dumps in a structured format.
- Automatic generation of backup filenames with date and time.
- Archive backups in ZIP format.
- Send backups via email.
- Easy to integrate into existing PHP projects.

Requirements
------------

[](#requirements)

- PHP version 8.0 or **higher**
- PDO extension **enabled**
- ZipArchive extension **enabled**
- PHPMailer
- MySQL database
- Composer (for installation)

Installation
------------

[](#installation)

This library can be easily installed using [Composer](https://getcomposer.org/), a modern PHP dependency manager.

### Step 1: Install Composer

[](#step-1-install-composer)

If you don't have Composer installed, you can download and install it by following the instructions on the [official Composer website](https://getcomposer.org/download/).

### Step 2: Install the Library

[](#step-2-install-the-library)

Once Composer is installed, you can install the `mysql-backup` library by running the following command in your project's root directory:

```
composer require ramazancetinkaya/mysql-backup
```

Usage
-----

[](#usage)

```
require 'vendor/autoload.php'; // Include Composer's autoloader

use DatabaseBackupManager\MySQLBackup;

// Initialize PDO connection
$db = new PDO('mysql:host=localhost;dbname=my_database', 'username', 'password');

// Create an instance of MySQLBackup
$mysqlBackup = new MySQLBackup($db);
```

- Perform a database backup:

```
// Backs up all tables
$backup = $mysqlBackup->backup();

// Backs up the specified tables
$backup = $mysqlBackup->backup(['tablename1']);
$backup = $mysqlBackup->backup(['tablename1', 'tablename2']);

// Include table data in the backup or vice versa
$backup = $mysqlBackup->backup(null, true); // Default is true

// Archiving
$backup = $mysqlBackup->backup(null, true, false); // Default is false

// Send the backup file by email
$backup = $mysqlBackup->backup(null, true, true, 'recipient@example.com'); // Default is null

if ($backup) {
    echo "Database backup created successfully.";
} else {
    echo "Database backup failed!";
}
```

- Perform a database restore:

```
// Restore a database
$backupFile = 'backup_wordpress-2024-05-09_214345.sql';
$restore = $mysqlBackup->restore($backupFile);

// Whether to drop existing tables before restoring data
$restore = $mysqlBackup->restore($backupFile, true); // Default is true

if ($restore) {
    echo "Database restored successfully.";
} else {
    echo "Database restoration failed!";
}
```

Disclaimer
----------

[](#disclaimer)

This library is provided as-is without any warranties, expressed or implied. The use of this library is at your own risk, and the developers will not be liable for any damages or losses resulting from its use.

While every effort has been made to ensure the accuracy and reliability of the code in this library, it's important to understand that no guarantee is provided regarding its correctness or suitability for any purpose.

Users are encouraged to review and test the functionality of this library in their own environments before deploying it in production or critical systems.

This disclaimer extends to all parts of the library and its documentation.

**By using the Library, you agree to these terms and conditions. If you do not agree with any part of this disclaimer, do not use the Library.**

---

This disclaimer was last updated on May 9, 2024.

Contributing
------------

[](#contributing)

Contributions are welcome! If you find any issues or have suggestions for improvements, feel free to open an issue or create a pull request.

Authors
-------

[](#authors)

- **Ramazan Çetinkaya** - [@ramazancetinkaya](https://github.com/ramazancetinkaya)

License
-------

[](#license)

This project is licensed under the MIT License. For more details, see the [LICENSE](LICENSE) file.

Copyright
---------

[](#copyright)

© 2024 Ramazan Çetinkaya. All rights reserved.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~41 days

Total

5

Last Release

564d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/10ce1471ebd6b863d30d635f15b7a60149aa69d59639725b30a02b30d685e817?d=identicon)[julio101290](/maintainers/julio101290)

---

Top Contributors

[![ramazancetinkaya](https://avatars.githubusercontent.com/u/75214035?v=4)](https://github.com/ramazancetinkaya "ramazancetinkaya (13 commits)")[![julio101290](https://avatars.githubusercontent.com/u/11257577?v=4)](https://github.com/julio101290 "julio101290 (6 commits)")

---

Tags

phpdatabasebackupmysqlpdorestorephpmailer

### Embed Badge

![Health badge](/badges/julio101290-mysql-backup/health.svg)

```
[![Health](https://phpackages.com/badges/julio101290-mysql-backup/health.svg)](https://phpackages.com/packages/julio101290-mysql-backup)
```

###  Alternatives

[ifsnop/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k5.5M69](/packages/ifsnop-mysqldump-php)[clouddueling/mysqldump-php

PHP version of mysqldump cli that comes with MySQL

1.3k22.9k](/packages/clouddueling-mysqldump-php)[rah/danpu

Zero-dependency MySQL dump library for easily exporting and importing databases

64401.8k10](/packages/rah-danpu)[popphp/pop-db

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)[riverside/php-orm

PHP ORM micro-library and query builder

111.2k](/packages/riverside-php-orm)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
