Skip to content

tayfunerbilen/backuphp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

BackupPHP

I prepared this class in lecture that I published on my Youtube channel.

If you watching lectures;

MySQL Backup Lecture | Folder Backup Lecture

First, you need to initialize Backup class.

$backup = new Backup();

For mysql backup;

try {
    $mysqlBackup = $backup->mysql([
        'host' => 'localhost',
        'user' => '',
        'pass' => '',
        'dbname' => '',
        'file' => __DIR__ . '/backup.sql'
    ]);
    if ($mysqlBackup){
        echo 'success';
    }
} catch (Exception $e){
    die($e->getMessage());
}

For folder backup;

try {
    $folderBackup = $backup->folder([
        'dir' => 'cms',
        'file' => 'backup.zip',
        'exclude' => ['.idea', 'upload', 'vendor'] // exclude these files while backup
    ]);
    if ($folderBackup){
        echo 'success';
    }
} catch (Exception $e){
    die($e->getMessage());
}

For full backup;

try {
    $backup = new Backup([
        'db' => [
            'host' => 'localhost',
            'user' => '',
            'pass' => '',
            'dbname' => '',
            'file' => __DIR__ . '/backup.sql'
        ],
        'folder' => [
            'dir' => 'cms', // directory name
            'file' => 'full_backup.zip',
            'exclude' => ['.idea', 'upload', 'vendor'] // exclude these files while backup
        ]
    ]);
    $yedekle = $backup->full();
    if ($yedekle){
        echo 'success';
    }
} catch (Exception $e){
    die($e->getMessage());
}

About

Backup mysql and folders using PHP

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages