Download the PHP package indiehd/mysql-db-backup without Composer

On this page you can find all versions of the php package indiehd/mysql-db-backup. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package mysql-db-backup

MySQL Database Backup

A PHP CLI tool for automated MySQL/MariaDB database backups with intelligent deduplication and compression.

Features

Requirements

Docker Setup Prerequisites

If using Docker (recommended), ensure your user has Docker permissions:

Database User Setup

Choose Your Deployment Scenario

Pick the option that matches your setup:

Scenario User Setup Network Mode Best For
A: Localhost MySQL 'backup'@'localhost' --network host Single server, MySQL on localhost (simplest)
B: Isolated Container 'backup'@'%' bridge (default) Better isolation, any Docker setup
C: Multi-Container 'backup'@'%' Custom network MySQL in another container

Scenario A: Localhost MySQL (Recommended for Single Server)

Best for: MySQL/MariaDB running on the same server as Docker

Configuration (.env):

Important: Use 127.0.0.1, NOT localhost! See .env.example for explanation.

Security: Most secure - only accepts connections from localhost

Scenario B: Bridge Network (Better Isolation)

Best for: When you want container isolation or don't want to use --network host

Configuration (.env):

Security: Good - relies on password auth and firewall. Ensure MySQL is not exposed to internet!

Scenario C: Multi-Container Setup

Best for: MySQL running in another Docker container

Configuration (.env):

Quick Reference: Permission Grants

The minimum permissions needed for backups:

Quick Start (Docker - Recommended)

Complete setup in 5 minutes for localhost MySQL:

Done! Your backups will run daily at 2 AM. ✅

Installation

Via Composer (Recommended)

Manual Installation

Configuration

Option 1: Configuration File (Recommended)

Copy the example configuration file and customize it:

Edit db-backup.ini:

Note: The password field is optional if you're using socket-based authentication (e.g., auth_socket plugin in MariaDB).

Option 2: Environment Variables

You can also configure using environment variables:

Usage

Command Line

If installed via Composer:

If installed globally or from project directory:

Cron Job Setup

To run automated backups daily at 2 AM:

Add this line:

Or if using environment variables:

Docker Usage

For complete Docker deployment guide, see DOCKER.md

Quick Start with Docker

The run-backup.sh script automatically handles different network modes based on your .env configuration.

Manual Docker Run (if not using run-backup.sh)

Scenario A - Host Network:

Scenario B - Bridge Network:

Scenario C - Custom Network:

Using docker-compose

How It Works

  1. Connect to MySQL/MariaDB server
  2. List all databases (excluding system databases: mysql, information_schema, performance_schema, sys)
  3. Dump each database using mysqldump with optimized flags
  4. Compare the new backup hash with the previous backup
  5. Skip if identical (no changes detected)
  6. Compress with gzip if new data is present
  7. Store in organized directory structure: <dumpdir>/<database>/<YYYYMMDDHHmm>.sql.gz

Backup Optimization

The tool uses SHA1 hash comparison to avoid storing duplicate backups when database content hasn't changed. This saves significant storage space for databases that don't change frequently.

The dump files are created without comments (via --skip-comments) to ensure hash comparison works correctly, as comments include timestamps that would always differ.

Directory Structure

Backup Retention

Important: This tool does NOT automatically delete old backups. Backups will accumulate over time.

Recommended: Add a Cleanup Cron Job

To prevent unlimited backup growth, add a retention policy:

Common retention periods:

Future Enhancement: Built-in retention policies are planned for a future release.

Troubleshooting

Permission Issues

Ensure the backup directory is writable:

MySQL Connection Issues

Test your connection:

Missing Dependencies

Verify required executables are available:

License

GNU General Public License v3.0 or later (GPL-3.0-or-later)

Author

Ben Johnson ([email protected])

Copyright (c) 2012-2026, Ben Johnson


All versions of mysql-db-backup with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
ext-mysqli Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package indiehd/mysql-db-backup contains the following files

Loading the files please wait ...