2017 © Pedro Peláez
 

yii2-extension yii2-db-archiver

DbArchiver archive and restore old data from DB to file by Yii2 ActiveRecord models. For big tables allow direct file export from MySQL database(fast archiving, but file save only on MySQL server drive)

image

burn/yii2-db-archiver

DbArchiver archive and restore old data from DB to file by Yii2 ActiveRecord models. For big tables allow direct file export from MySQL database(fast archiving, but file save only on MySQL server drive)

  • Thursday, July 16, 2015
  • by burnb
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2,590 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Yii2 DB Archiver.

What is this?

DbArchiver archive and restore old data from db to file by Yii2 ActiveRecord models. For big tables allow direct file export from MySQL database(fast archiving, but file save only on MySQL server drive)., (*1)


Installation

Yii2 framework and PHP 5.4 or higher is required to use it., (*2)

Installation is recommended to be done via [composer][] by adding the following to the require section in your composer.json:, (*3)

"burn/yii2-db-archiver": "dev-master"

Run composer update afterwards., (*4)

Usage:

At first set in main app config dbArchiver component like this:, (*5)

    'components' => [
            'dbArchiver' => [
                'class'    => 'burn\dbArchiver\DbArchiver',
                'dumpPath' => '/home/'
            ]
        ],

Example console action, using DbArchiver component for large table with direct archiving and date column in Unix timestamp format:, (*6)

  /**
   * @throws \yii\base\InvalidConfigException
   */
  public function actionArchiveErrorsLog()
  {
      /** @var \burn\dbArchiver\DbArchiver $dbArchiver */
      $dbArchiver = \Yii::$app->get('dbArchiver');
      $dbArchiver
          ->getQuery()
          ->setArchivedModel(LogError::className())
          ->setDirect(true)
          ->setDateColumn('log_time')
          ->setMkTimeDateColumn(true);
      if (!$dbArchiver->actionArchive()) {
          \Yii::error(LogError::tableName() . ' table not archived!');
          echo 'Something went wrong! '. LogError::tableName() . ' table not archived!';
      }
  }

Example of restore console action:, (*7)

    /**
    * @throws \yii\base\InvalidConfigException
    */
    public function actionRestoreErrorsLog($filename)
    {
        /** @var \burn\dbArchiver\DbArchiver $dbArchiver */
        $dbArchiver = \Yii::$app->get('dbArchiver');
        $dbArchiver
            ->getQuery()
            ->setArchivedModel(LogError::className())
            ->setDirect(true);
        if (!$dbArchiver->actionRestoreFromFile($filename)) {
            \Yii::error(LogError::tableName() . ' table not restored!');
            echo 'Something went wrong! '. LogError::tableName() . ' table not restored!';
        }
    }

The Versions

16/07 2015

dev-master

9999999-dev

DbArchiver archive and restore old data from DB to file by Yii2 ActiveRecord models. For big tables allow direct file export from MySQL database(fast archiving, but file save only on MySQL server drive)

  Sources   Download

BSD-4-Clause

The Requires

 

by Petrov Aleksandr

extension yii2 mysql db dump archive archiver

16/07 2015

1.0.2

1.0.2.0

DbArchiver archive and restore old data from DB to file by Yii2 ActiveRecord models. For big tables allow direct file export from MySQL database(fast archiving, but file save only on MySQL server drive)

  Sources   Download

BSD-4-Clause

The Requires

 

by Petrov Aleksandr

extension yii2 mysql db dump archive archiver

15/07 2015

1.0.1

1.0.1.0

DbArchiver archive and restore old data from DB to file by Yii2 ActiveRecord models. For big tables allow direct file export from MySQL database(fast archiving, but file save only on MySQL server drive)

  Sources   Download

BSD-4-Clause

The Requires

 

by Petrov Aleksandr

extension yii2 mysql db dump archive archiver

05/07 2015

v1.0.0

1.0.0.0

Archive old data from db to file.

  Sources   Download

BSD-4-Clause

The Requires

 

by Petrov Aleksandr

extension yii2 mysql db dump archive archiver

05/07 2015

dev-feature/addNotDirectArchiving

dev-feature/addNotDirectArchiving

Archive old data from db to file.

  Sources   Download

BSD-4-Clause

The Requires

 

by Petrov Aleksandr

extension yii2 mysql db dump archive archiver