PHP code example of cocolait / backup

1. Go to this page and download the library: Download cocolait/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/ */

    

cocolait / backup example snippets


composer 


// 加载扩展 TODO 如果你使用的框架已支持composer那么这一行可直接忽略
��份数据 默认false',['is_compress' => '是否写入内容文件进行压缩','is_download' => '是否进行下载'])
$config = [
        // 服务器地址
        'host'        => 'xx.xx.xx.xx',
        // 数据库名
        'database'    => 'xxx',
        // 用户名
        'user'        => 'xxx',
        // 密码
        'password'    => 'xxx',
        // 端口
        'port'        => '3306',
        // 字符编码
        'charset'     => 'utf8'
];
// 备份
$dir = "./backup/sql";//备份路径
$data = cocolait\sql\Backup::instance($config)->backUp($dir,[],true,['is_compress' => 0]);
print_r($data);die;

// 还原
$data = cocolait\sql\Backup::instance($config)->recover('xxx_20180512072455_194757120.sql',$dir);
print_r($data);die;