PHPackages                             jamielsharief/chronos - 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. jamielsharief/chronos

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

jamielsharief/chronos
=====================

Chronos Database Backup Restore

0.1.6(4y ago)317MITPHPPHP &gt;=7.3.0

Since Jan 17Pushed 4y ago1 watchersCompare

[ Source](https://github.com/jamielsharief/chronos)[ Packagist](https://packagist.org/packages/jamielsharief/chronos)[ RSS](/packages/jamielsharief-chronos/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (8)Versions (8)Used By (0)

Chronos Database Backup &amp; Restore
=====================================

[](#chronos-database-backup--restore)

[![license](https://camo.githubusercontent.com/6fdb99389fe9d9e8a5c197002a191ace7c8b12a2020c0fa5756cf17aa08a4966/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874477265656e2e737667)](https://camo.githubusercontent.com/6fdb99389fe9d9e8a5c197002a191ace7c8b12a2020c0fa5756cf17aa08a4966/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874477265656e2e737667)[![build](https://github.com/jamielsharief/chronos/workflows/CI/badge.svg)](https://github.com/jamielsharief/chronos/actions)[![coverage](https://camo.githubusercontent.com/366b30a9d54db208a17f097817bfefc31462b5b54e13e6093f1c3daec9058f91/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6a616d69656c736861726965662f6368726f6e6f732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/jamielsharief/chronos?branch=master)

Chronos Database Backup and Restore provides easy and painless backups of your MySQL, Postgres and Sqlite databases.

Each process, wether dumping, compression or encryption is handled by the specific binary application and then the relevant extension is appened to the output filename. For example, `chronos` does not compress using `gpg` nor encrypt with `7zip`. This means the trail on how backups were created can easily be followed, and thus can be unpacked without `chronos`, if needed.

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

[](#requirements)

- `mysqldump` if you are going to backup MySQL databases
- `pgdump` if you are going to backup Postgres databases
- `gpg`,`openssl` if you want to encrypt/decrpyt data
- `bzip2`,`gzip`,`7zip` or `zip` executable binaries if you want to compress backups

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

[](#installation)

To install this package

```
$ composer require jamielsharief/chronos

```

Create a folder where you will store your backups, and set the permissions so you can write to it, assuming you are a member of the `www-data` group, for example

```
$ mkdir /backups
$ chown www-data:www-data /backups
$ chmod 0775 /backups
```

Usage
-----

[](#usage)

First you need to initialize your installation which creates `chronos.json` in your project folder with the database settings.

```
$ vendor/bin/chronos init
          __
    _____/ /_  _________  ____  ____  _____
   / ___/ __ \/ ___/ __ \/ __ \/ __ \/ ___/
  / /__/ / / / /  / /_/ / / / / /_/ (__  )
  \___/_/ /_/_/   \____/_/ /_/\____/____/

version 0.1.0

Starting chronos initialization
Engine  (mysql/postgres/sqlite) [mysql]
> mysql

Host [localhost]
> mysql

Port [3306]
> 3306

Username [root]
> root

Password
>

Backup directory
> /backups/crm

Enter the default database name to backup.
Database name
>

[ OK ] chronos.json saved
```

> Are you installing on a server with multiple applications? if so it could be be a good idea to setup a folder within your backup folder for each application , e.g. `/backups/crm`, `/backups/helpdesk`

If you provided a default database during setup, then you can simply run the backup command and this will backup up the database(s) listed in `chronos.json`, if there are no databases configured then `chronos` will show you a list of databases asking you yo choose one.

```
$ vendor/bin/chronos backup
```

If you didnt or want to backup different databases then you can pass the database names as arguments.

```
$ vendor/bin/chronos backup bookmarks
          __
    _____/ /_  _________  ____  ____  _____
   / ___/ __ \/ ___/ __ \/ __ \/ __ \/ ___/
  / /__/ / / / /  / /_/ / / / / /_/ (__  )
  \___/_/ /_/_/   \____/_/ /_/\____/____/

version 0.1.0

[ OK ] Backup 'bookmarks'

Took 0.06 seconds
```

You can also backup multiple databases at the same time

```
$ vendor/bin/chronos backup crm helpdesk accounting
```

To use compression, simply supply the compression type `7zip`, `bzip2`, `gzip`, `unzip` or `zip`.

```
$ vendor/bin/chronos backup --compress gzip
```

To encrypt your backups using `AES` you can use `gpg` or `ssl` which uses `openssl`.

```
$ vendor/bin/chronos backup --encrypt gpg # this will ask for password
$ CHRONOS_PASSWORD=secret vendor/bin/chronos backup crm --encrypt gpg # uses password from env var
```

To list backups

```
$ vendor/bin/chronos backup list
          __
    _____/ /_  _________  ____  ____  _____
   / ___/ __ \/ ___/ __ \/ __ \/ __ \/ ___/
  / /__/ / / / /  / /_/ / / / / /_/ (__  )
  \___/_/ /_/_/   \____/_/ /_/\____/____/

version 0.1.0

Backups path: /backups/bookmarks
+----------------------+--------------------------------------+----------+
| Date                 | Backup                               | Size     |
+----------------------+--------------------------------------+----------+
| 2021-01-16 14:11:15  | bookmarks-20210116141115.sql.7z.gpg  | 1.48 KB  |
| 2021-01-16 14:10:56  | bookmarks-20210116141056.sql.gpg     | 4.23 KB  |
| 2021-01-16 14:10:46  | bookmarks-20210116141046.sql.zip     | 1.53 KB  |
| 2021-01-16 14:10:42  | bookmarks-20210116141042.sql         | 4.21 KB  |
+----------------------+--------------------------------------+----------+
```

To restore a backup

```
$ vendor/bin/chronos restore bookmarks-20210116132550.sql.bz2
          __
    _____/ /_  _________  ____  ____  _____
   / ___/ __ \/ ___/ __ \/ __ \/ __ \/ ___/
  / /__/ / / / /  / /_/ / / / / /_/ (__  )
  \___/_/ /_/_/   \____/_/ /_/\____/____/

version 0.1.0

 WARNING   Database 'bookmarks' already exists
Existing data will be overwritten, continue?  (yes/no) [no]
> yes

[ SKIPPED ] Create database 'bookmarks'
[ OK ] Restore 'bookmarks' from 'bookmarks-20210116132550.sql.bz2'

Took 1.22 seconds
```

If you want to restore the backup to a different database than from what it was created

```
$ vendor/bin/chronos restore bookmarks-20210116132550.sql.bz2
```

When restoring backups, if the file is encrypted it will prompt you for a password.

Compression
-----------

[](#compression)

Backups can be compressed using using `bzip2`,`gzip`,`7zip` and `zip`.

Depending upon your linux distribution you might need to install the relevant binary. For brevity I have put all compression packages in one line, however you can install just the one or ones that you want.

Ubuntu/Debian

```
$ apt install bzip2 zip gzip p7zip-full

```

For Redhat/CentOS/Fedora

> 7zip packages are in the EPEL repository and needs to be enabled install

```
$ yum install bzip2 zip gzip p7zip p7zip-plugins
```

If a dump is compressed, the filename will be appened with `bz2`,`gz`,`7z` or `zip`.

### Compression Comparison

[](#compression-comparison)

I carried out a simple test using a single table with `1,000` and `10,000` records with random data.

This is how I generated the data

```
$post = $this->Post->new([
    'title' => uniqid(), // random 13 char string
    'body' => Security::hex(16), // random 16 char string
    'published' => rand(0, 1)
]);
```

These are the results that I got

```
                1,000       10,000
sql             76.42 KB    770.76 KB
bzip2           18.93 KB    147.25 KB
gzip            18.93 KB    185.42 KB
zip             19.12 KB    185.52 KB
7zip            13.97 KB    133.31 KB

```

Encryption
----------

[](#encryption)

Encryption is carried out after compression to be effective, however it some cases it could become less secure due to [side channel attacks](https://www.iacr.org/cryptodb/archive/2002/FSE/3091/3091.pdf).

### GPG (recommended)

[](#gpg-recommended)

[NASA recommend](https://www.nas.nasa.gov/hecc/support/kb/using-gpg-to-encrypt-your-data_242.html) using GPG for file encryption, and this is easily installed on linux operating systems (if not already)

For Ubuntu/Debian

```
$ sudo apt install gnupg
```

For Redhat/CentOS/Fedora

```
$ sudo yum install gnupg
```

### OpenSSL (deprecated)

[](#openssl-deprecated)

> Use GPG instead

To use this encryption engine, you need `openssl` to be installed, this is already on linux systems, but on the Mac `libressl` is included but that does not support does not support `pbkdf2` or `iter`. Both these features [improve security](https://courses.csail.mit.edu/6.857/2018/project/Ainane-Barrett-Johnson-Vivar-OpenSSL.pdf) and should be used.

Encrypting data is touchy with `openssl` because the settings used to encrypt needs to same when decrypting, therefore you can't be encrypting data on different installations in different ways. Major changes to openssl could affect backup/restore operations.

On the MacOS you can install `openssl` simply like this

```
$ brew update
$ brew install openssl
```

If a dump is encrypted with `openssl` it will have the `enc` extension added.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

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 ~40 days

Recently: every ~60 days

Total

7

Last Release

1696d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7718a059aa8ef3d6e9f6e5bd7f4d5b09b7321a059f2669e61546d1a665fbb372?d=identicon)[jamielsharief](/maintainers/jamielsharief)

---

Top Contributors

[![jamielsharief](https://avatars.githubusercontent.com/u/20553479?v=4)](https://github.com/jamielsharief "jamielsharief (33 commits)")

---

Tags

7zipaesbackupbzip2compressionencryptiongzipmysqlphppostgresrestoresqlitezipbackupmysqlsqlitepostgresmariadbrestore

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/jamielsharief-chronos/health.svg)

```
[![Health](https://phpackages.com/badges/jamielsharief-chronos/health.svg)](https://phpackages.com/packages/jamielsharief-chronos)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k578.4M5.6k](/packages/doctrine-dbal)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58523.9M35](/packages/scienta-doctrine-json-functions)[catfan/medoo

The lightweight PHP database framework to accelerate development

4.9k1.5M193](/packages/catfan-medoo)[aura/sql

A PDO extension that provides lazy connections, array quoting, query profiling, value binding, and convenience methods for common fetch styles. Because it extends PDO, existing code that uses PDO can use this without any changes to the existing code.

5632.5M43](/packages/aura-sql)[aura/sqlquery

Object-oriented query builders for MySQL, Postgres, SQLite, and SQLServer; can be used with any database connection library.

4572.9M34](/packages/aura-sqlquery)[phpbu/phpbu

PHP Backup utility.

1.3k89.0k4](/packages/phpbu-phpbu)

PHPackages © 2026

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