PHPackages                             marekskopal/mariadb-backup-aws - 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. marekskopal/mariadb-backup-aws

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

marekskopal/mariadb-backup-aws
==============================

MariaDB backup to AWS S3

v1.0.0(1w ago)03MITPHPPHP &gt;=8.4CI passing

Since Nov 6Pushed 1w ago1 watchersCompare

[ Source](https://github.com/marekskopal/mariadb-backup-aws)[ Packagist](https://packagist.org/packages/marekskopal/mariadb-backup-aws)[ RSS](/packages/marekskopal-mariadb-backup-aws/feed)WikiDiscussions main Synced today

READMEChangelog (4)Dependencies (39)Versions (6)Used By (0)

MariaDB Backup to AWS S3
========================

[](#mariadb-backup-to-aws-s3)

[![CI](https://github.com/marekskopal/mariadb-backup-aws/actions/workflows/ci.yml/badge.svg)](https://github.com/marekskopal/mariadb-backup-aws/actions/workflows/ci.yml)[![Latest Version](https://camo.githubusercontent.com/a639dbd6c3b0d09f6dcbdc4f17d3e3e4aff00d5bd9a3754c93389f00b86c691f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d6172656b736b6f70616c2f6d6172696164622d6261636b75702d6177732e737667)](https://packagist.org/packages/marekskopal/mariadb-backup-aws)[![Docker Pulls](https://camo.githubusercontent.com/9b180af7135712b008b216692c0ad34d5d3e61e338ba469fa8a51820ce4ccc03/68747470733a2f2f696d672e736869656c64732e696f2f646f636b65722f70756c6c732f6d6172656b736b6f70616c2f6d6172696164622d6261636b75702d6177732e737667)](https://hub.docker.com/r/marekskopal/mariadb-backup-aws)[![PHP Version](https://camo.githubusercontent.com/c11e1df40d8b8ec95e6aa5d06cc21a93aaf720613e5dd5c303002f613255b74f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6172656b736b6f70616c2f6d6172696164622d6261636b75702d6177732e737667)](https://packagist.org/packages/marekskopal/mariadb-backup-aws)[![License](https://camo.githubusercontent.com/b4e999b24dfedadbeeb70bc2c484a987290c616ed69baab94634709e8dcbc28c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6172656b736b6f70616c2f6d6172696164622d6261636b75702d6177732e737667)](LICENSE)

A small, dependable CLI tool that dumps one or more MariaDB databases, compresses the dump, uploads it to AWS S3, and rotates old backups automatically. Ships as a Composer package and as a ready-to-run Docker image with a built-in daily schedule.

Features
--------

[](#features)

- **Consistent, complete dumps** — uses `--single-transaction` (a non-locking, point-in-time snapshot of InnoDB) together with `--routines`, `--events` and `--triggers`, and accepts extra `mariadb-dump` options when you need them.
- **Streamed gzip dumps** — `mariadb-dump` output is compressed on the fly; no large uncompressed file is kept on disk.
- **Fails loudly, never silently** — the real `mariadb-dump` exit code is checked and an empty dump is rejected, so a broken backup is never uploaded or rotated in.
- **Credentials stay private** — the database password is passed through a temporary `--defaults-extra-file`, never on the command line, so it does not appear in the process list. The temporary dump is written with `0600` permissions and always cleaned up.
- **Encrypted at rest** — uploads request S3 server-side encryption (AES‑256).
- **Automatic rotation** — keeps the newest *N* backups and deletes the rest (paginated, so it scales past 1000 objects).
- **Flexible scope** — back up a single database, a comma-separated list, or all databases.
- **Configurable two ways** — every setting can be provided as a CLI option or an environment variable.

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

[](#requirements)

- PHP ≥ 8.4 with the `mariadb-dump` client available on `PATH` (already included in the Docker image)
- An AWS S3 bucket and credentials with `PutObject`, `ListBucket`, and `DeleteObject` permissions

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

[](#installation)

### Docker (recommended)

[](#docker-recommended)

The image is published on [Docker Hub](https://hub.docker.com/r/marekskopal/mariadb-backup-aws) and runs the backup on a daily schedule (01:00) via Supercronic.

```
docker pull marekskopal/mariadb-backup-aws:latest
```

### Composer

[](#composer)

```
composer require marekskopal/mariadb-backup-aws
```

Configuration
-------------

[](#configuration)

Each option can be set via a CLI flag or an environment variable. CLI options take precedence; if neither is set, the listed default is used (or the command fails for required values).

CLI optionShortEnvironment variableRequiredDefaultDescription`--host``-H``DB_HOST`yes—MariaDB host`--port``-P``DB_PORT`no`3306`MariaDB port`--user``-u``DB_USER`yes—MariaDB user`--password``-p``DB_PASSWORD`yes—MariaDB password`--database``-d``DB_DATABASE`no*(all)*Database name; comma-separated for several; all databases if empty`--dump-options`—`DB_DUMP_OPTIONS`no—Extra `mariadb-dump` options (space-separated), appended to defaults`--aws-access-key``-a``AWS_ACCESS_KEY`yes—AWS access key`--aws-secret``-s``AWS_SECRET_ACCESS_KEY`yes—AWS secret access key`--aws-region``-r``AWS_REGION`yes—AWS region`--aws-bucket``-b``AWS_BUCKET`yes—S3 bucket name`--aws-root-path``-o``AWS_ROOT_PATH`no`backup`Key prefix for backups within the bucket`--aws-max-backups``-m``AWS_MAX_BACKUPS`no`30`Number of backups to retain (must be ≥ 1)Backups are stored under:

```
{AWS_ROOT_PATH}/{YYYY-MM-DD}/{timestamp}.sql.gz

```

Usage
-----

[](#usage)

### Docker Compose

[](#docker-compose)

Define the configuration in your `.env` file:

```
DB_HOST=your_db_host
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_DATABASE=your_db_name

AWS_ACCESS_KEY=your_aws_key
AWS_SECRET_ACCESS_KEY=your_aws_secret
AWS_REGION=your_aws_region
AWS_BUCKET=your_aws_bucket
AWS_ROOT_PATH=backup
AWS_MAX_BACKUPS=30
```

Add the service to your `docker-compose.yml`:

```
services:
    mariadb-backup-aws:
        image: marekskopal/mariadb-backup-aws:latest
        environment:
            DB_HOST: ${DB_HOST}
            DB_DATABASE: ${DB_DATABASE}
            DB_USER: ${DB_USER}
            DB_PASSWORD: ${DB_PASSWORD}
            AWS_ACCESS_KEY: ${AWS_ACCESS_KEY}
            AWS_SECRET_ACCESS_KEY: ${AWS_SECRET_ACCESS_KEY}
            AWS_REGION: ${AWS_REGION}
            AWS_BUCKET: ${AWS_BUCKET}
            AWS_ROOT_PATH: ${AWS_ROOT_PATH:-backup}
            AWS_MAX_BACKUPS: ${AWS_MAX_BACKUPS:-30}
        restart: unless-stopped
```

```
docker compose up -d
```

The container runs the backup every day at 01:00 (logs to `/app/log/cron.log`). To run it once on demand:

```
docker compose exec mariadb-backup-aws bin/console mariaDbBackup:aws
```

### Composer (CLI)

[](#composer-cli)

```
./vendor/marekskopal/mariadb-backup-aws/bin/console mariaDbBackup:aws \
  --host=your_db_host \
  --user=your_db_user \
  --password=your_db_password \
  --database=your_db_name \
  --aws-access-key=your_aws_key \
  --aws-secret=your_aws_secret \
  --aws-region=your_aws_region \
  --aws-bucket=your_aws_bucket
```

Omit `--database` to back up all databases, or pass a comma-separated list (e.g. `--database=app,reporting`).

How it works
------------

[](#how-it-works)

1. `mariadb-dump` is launched via `proc_open` (no shell), with credentials and port supplied through a temporary `0600` option file, using a consistent, complete set of dump options.
2. Its stdout is streamed through gzip into a temporary `0600` file. The exit code and output are verified.
3. The compressed dump is uploaded to S3 with AES‑256 server-side encryption.
4. Objects under the prefix are listed and the oldest beyond `AWS_MAX_BACKUPS` are deleted.
5. The local temporary file is removed — even if the dump or upload fails.

Development
-----------

[](#development)

```
composer install

vendor/bin/phpunit      # tests
vendor/bin/phpstan analyse   # static analysis (level 9)
vendor/bin/phpcs        # coding standard
```

License
-------

[](#license)

Released under the [MIT License](LICENSE).

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance90

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~148 days

Total

5

Last Release

12d ago

Major Versions

v0.3.1 → v1.0.02026-06-21

PHP version history (2 changes)v0.1.0PHP &gt;=8.3

v1.0.0PHP &gt;=8.4

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/33967656?v=4)[Marek Skopal](/maintainers/marekskopal)[@marekskopal](https://github.com/marekskopal)

---

Top Contributors

[![marekskopal](https://avatars.githubusercontent.com/u/33967656?v=4)](https://github.com/marekskopal "marekskopal (38 commits)")

---

Tags

s3awsdatabasebackupmariadb

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/marekskopal-mariadb-backup-aws/health.svg)

```
[![Health](https://phpackages.com/badges/marekskopal-mariadb-backup-aws/health.svg)](https://phpackages.com/packages/marekskopal-mariadb-backup-aws)
```

###  Alternatives

[spatie/laravel-backup

A Laravel package to backup your application

6.0k24.4M243](/packages/spatie-laravel-backup)[backup-manager/symfony

A simple database backup manager for Symfony2 with support for S3, Rackspace, Dropbox, FTP, SFTP.

123298.8k3](/packages/backup-manager-symfony)[perplorm/perpl

Perpl is an improved and still maintained fork of Propel2, an open-source Object-Relational Mapping (ORM) for PHP.

2411.8k](/packages/perplorm-perpl)

PHPackages © 2026

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