PHPackages                             floor12/yii2-module-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. floor12/yii2-module-backup

ActiveYii2-extension[Utility &amp; Helpers](/categories/utility)

floor12/yii2-module-backup
==========================

Yii2 backup module

1.2.3(3y ago)64274[7 issues](https://github.com/floor12/yii2-module-backup/issues)1MITPHPCI failing

Since Dec 9Pushed 1y ago1 watchersCompare

[ Source](https://github.com/floor12/yii2-module-backup)[ Packagist](https://packagist.org/packages/floor12/yii2-module-backup)[ Docs](https://github.com/dragonjet/yii2-module-backup)[ RSS](/packages/floor12-yii2-module-backup/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (4)Versions (10)Used By (1)

yii2-module-backup
==================

[](#yii2-module-backup)

[![Build Status](https://camo.githubusercontent.com/ba95ba1af278b20250a5d496e9f7f8ed8604263826897963f348fedb05eb3518/68747470733a2f2f7472617669732d63692e6f72672f666c6f6f7231322f796969322d6d6f64756c652d66696c65732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/floor12/yii2-module-backup)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7bc6123f2a41a6cb392dfdcd595a21c3c997df1976aa1816384d237c6e49b2b1/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f666c6f6f7231322f796969322d6d6f64756c652d6261636b75702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/floor12/yii2-module-backup/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/f04f21db24057e9fffb0706e9d2671c5a5679fc01dc3f47bcf15524807b52f71/68747470733a2f2f706f7365722e707567782e6f72672f666c6f6f7231322f796969322d6d6f64756c652d6261636b75702f762f737461626c65)](https://packagist.org/packages/floor12/yii2-module-backup)[![Latest Unstable Version](https://camo.githubusercontent.com/7d6d094ce257bd5b47d1d3e3a1c564270a0509b92bf80d77619ba4a4b17e18a4/68747470733a2f2f706f7365722e707567782e6f72672f666c6f6f7231322f796969322d6d6f64756c652d6261636b75702f762f756e737461626c65)](https://packagist.org/packages/floor12/yii2-module-backup)[![Total Downloads](https://camo.githubusercontent.com/653a84a6617037376cf4e15d16bde4a72925407bc990546a4680eb4c11856ced/68747470733a2f2f706f7365722e707567782e6f72672f666c6f6f7231322f796969322d6d6f64756c652d6261636b75702f646f776e6c6f616473)](https://packagist.org/packages/floor12/yii2-module-backup)[![License](https://camo.githubusercontent.com/3a060ae09cf362369a7f47604d43d6936f975855695516ff7f4da08775d1ece2/68747470733a2f2f706f7365722e707567782e6f72672f666c6f6f7231322f796969322d6d6f64756c652d6261636b75702f6c6963656e7365)](https://packagist.org/packages/floor12/yii2-module-backup)

*Этот файл доступен на [русском языке](README_RU.md).*

This module helps to create and restore backups of databases and files stored on disk. It has web-interface, console commands, and REST-API for remote control. It also supports io-priority settings and has flexible configuration options. To work independently of the application database, this module uses its sqlite database in the backup folder.

Creating and restoring database backups is possible for [MySQL](https://www.mysql.com/) and \[PostgreSQL\] (). To do this, you must have the console client installed on the system for your database type. After a series of experiments, it became clear that creating and restoring databases best using their native clients.

### i18n

[](#i18n)

Now, this module supports English and Russian languages.

[![Yii backup module](https://camo.githubusercontent.com/c3b41ffa1722393ee6987cfb806a1f6f363d41ab60da9533b75b178f30fa4de5/68747470733a2f2f666c6f6f7231322e6e65742f66696c65732f64656661756c742f6765743f686173683d3438393536383565333339326164653465306532613430613736326263346665)](https://camo.githubusercontent.com/c3b41ffa1722393ee6987cfb806a1f6f363d41ab60da9533b75b178f30fa4de5/68747470733a2f2f666c6f6f7231322e6e65742f66696c65732f64656661756c742f6765743f686173683d3438393536383565333339326164653465306532613430613736326263346665)

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

[](#installation)

To add this module to your app, just run:

```
$ composer require floor12/yii2-module-backup
```

or add this to the `require` section of your composer.json.

```
"floor12/yii2-module-backup": "dev-master"
```

After that, include minimal module configuration in `modules` section of application config:

```
'modules' => [
           'backup' =>  [
               'class' => 'floor12\backup\Module',
               'backupFolder' => '/mnt/raid10/backups',
               'administratorRoleName' => '@',
               'configs' => [
                   'mysql_db' => [
                       'type' => BackupType::DB,
                       'title' => 'Mysql Database',
                       'connection' => 'db',  // component from app config, usually 'db'
                       'limit' => 0
                   ],
                   'postgres_db' => [
                       'type' => BackupType::DB,
                       'title' => 'PostgresQL database',
                       'connection' => 'example_connection_name', // component from app config, usually 'db'
                       'io' => IOPriority::REALTIME,
                       'limit' => 0
                   ],
                   'user_files_backup' => [
                       'type' => BackupType::FILES,
                       'title' => 'User uploaded files',
                       'path' => '@app/user_files',
                       'io' => IOPriority::IDLE,
                       'limit' => 0
                   ]
               ]
           ]
       ]
    ...
```

These parameters is possible to set up:

- `administratorRoleName` - role to access web controller
- `backupFolder` - path or alias to the place where the backups are stored (default is @app/backups)
- `chmod` - if this param has value, the new backup file will change mode after creation
- `authTokens` - array of auth tokens to use REST-API of the module
- `adminLayout` - it will change default `main` layout to something you need (if your admin panel has different base layout)

And the main and required param is `configs` - it`s an associative array of your backup configurations (folders and databases). Each backup item mast have these elements to set:

- a backup identifier as an array key, contains only letters and numbers without space;
- `type` - type backup: disk or database;
- `title` - human-readable backup item title to show in the admin interface;
- `limit` - how many backup copies keep before delete (`0` - never delete old copies);
- `io` - input/output hdd priority, use `floor12\backup\models\IOPriority` constants to keep it confabulated. Default value is `IOPriority::IDLE`;
- `connection` - in case of database backup, connection name in Yii2 config;
- `path` - in case of disk backup, the path to store backup files;

Usage
-----

[](#usage)

### WEB interface

[](#web-interface)

This module has a web controller to work with backups. Go to `backup/admin` or `backup/admin/index` to create, delete, restore and download backups.

### Console interface

[](#console-interface)

*To list all existing backups run*

```
$ ./yii backup/console/index
```

*To create config run*

```
$ ./yii backup/console/create
```

`backup_config_id` is backup item identifier from module configuration.

*To restore config run*

```
$ ./yii backup/console/restore
```

`backup_id` is identifier of backup stored in sqlite database

### REST-api

[](#rest-api)

By default, rest controller takes place on the route `/backup/api`. To get access to it, add header `Backup-Auth-Token` to request with one of the tokens stored in application config in the module section (param `authTokens`);

#### Get list of backups

[](#get-list-of-backups)

`GET /backup/api/index`

This is useful to remote backup checks from some dashboard with a few projects.

Response example:

```
[
  {
    "id": 8,
    "date": "2019-11-11 07:02:23",
    "status": 1,
    "type": 1,
    "config_id": "main_storage",
    "config_name": "TMP folder",
    "filename": "main_storage_2019-11-11_07-02-23.zip",
    "size": 4183
  },
  {
    "id": 7,
    "date": "2019-11-11 06:56:36",
    "status": 1,
    "type": 0,
    "config_id": "main_db",
    "config_name": "Main database",
    "filename": "main_db_2019-11-11_06-56-36.gz",
    "size": 753
  },

]
```

#### Create new backup

[](#create-new-backup)

`POST /backup/api/backup?config_id=`

Succes respons example:

```
{"result":"success"}
```

#### Restore from backup

[](#restore-from-backup)

`POST /backup/api/restore?id=`

Succes respons example:

```
{"result":"success"}
```

#### Delete backup

[](#delete-backup)

`DELETE /backup/api/delete?id=`

Succes respons example:

```
{"result":"success"}
```

#### Get backup file

[](#get-backup-file)

`GET /backup/api/get?id=`

This request will return backup archive with requested ID.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity67

Established project with proven stability

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

Recently: every ~218 days

Total

6

Last Release

1425d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8dc98d778cb18db41a1e5b9df722c56f65f655de44fe0d581484cd8dea31b928?d=identicon)[floor12](/maintainers/floor12)

---

Top Contributors

[![floor12](https://avatars.githubusercontent.com/u/8406969?v=4)](https://github.com/floor12 "floor12 (61 commits)")

---

Tags

backupzipyii2extensionmodulegzip

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/floor12-yii2-module-backup/health.svg)

```
[![Health](https://phpackages.com/badges/floor12-yii2-module-backup/health.svg)](https://phpackages.com/packages/floor12-yii2-module-backup)
```

###  Alternatives

[onmotion/yii2-telegram

Support chat for site based on Telegram bot

526.3k](/packages/onmotion-yii2-telegram)

PHPackages © 2026

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