1. Go to this page and download the library: Download amoracr/yii2-backup library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
amoracr / yii2-backup example snippets
'components' => [
...
'backup' => [
'class' => 'amoracr\backup\Backup',
// Path for storing the backups
'backupDir' => '@app/backups',
// Directories that will be added to backup
'directories' => [
// format: <inner backup filename> => <path/to/dir>
'images' => '@app/web/images',
'uploads' => '@app/web/uploads',
],
],
]
'components' => [
...
'backup' => [
'class' => 'amoracr\backup\Backup',
// Name for the backup
'fileName' => 'myapp-backup',
// Maximum age in seconds for a valid backup.
// Older files are considered deprecated and can be deleted.
// Minimum age is 86400 secs (1 day).
// Maximum age is 31536000 secs (1 year).
'expireTime'=> 86400 * 3,
// Path for storing the backups
'backupDir' => '@app/backups',
// Database components to backup
'databases' => ['db', 'db1'],
// Compression method to apply to backup file.
// Available options:
// 'none' or 'tar' for tar files, backup file is not compressed.
// 'bzip2' for tar.bz2 files, backup file is compressed with Bzip2 compression.
// 'gzip' for tar.gz files, backup file is compressed with Gzip compression.
// 'zip' for zip files, backup file is compressed with Zip compression.
'compression' => 'zip',
// Directories that will be added to backup
'directories' => [
// format: <inner backup filename> => <path/to/dir>
'images' => '@app/web/images',
'uploads' => '@app/web/uploads',
// format: <inner backup filename> => array('path'=><path/to/dir>,'regex'=><regular/expression/>)
// Key 'path' for setting the directory to