zafarjonovich/db-backuper

There is no license information available for the latest version (0.0.0.3) of this package.

0.0.0.3 2022-06-03 14:56 UTC

This package is auto-updated.

Last update: 2024-10-30 02:10:46 UTC


README

This package helps to you backup databases

Installation

The preferred way to install this extension is through composer.

Either run

composer require zafarjonovich/db-backuper

or add

"zafarjonovich/db-backuper": "*"

to the require section of your composer.json file.

Configuration

Simple usage, first create a backup runner file. For example, in the /home folder via name runner.php The backup folder must be pre-created, For example, let's create a db_backups folder for the /home folder

<?php

require_once 'vendor/autoload.php';

$credentials = [
    [
        'username' => 'username',
        'password' => 'password',
        'host' => 'localhost',
        'databaseName' => 'databaseName',
        'driver' => 'mysql',
        'charset' => 'utf8mb4',
        'directory' => '/home/db_backups',
        'namePrefix' => 'automated_backups_',
    ]
];

$backuper = new \zafarjonovich\DbBackuper\Backuper();
$backuper->backup($credentials);

Let's check, run the following command

/usr/bin/php7.4 /home/runner.php

If we look at /home/db_backups, the database will be backuped via named with current_time

Crontab configuration

If you need backup databaseses every n time, you must config crontab Run following command
crontab -e

And add this configuration

* * * * * /usr/bin/php7.4 /home/runner.php