PHP code example of coderatio / simple-backup

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

    

coderatio / simple-backup example snippets


  SimpleBackup::start()
    ->setDbName('db_name')
    ->setDbUser('db_username')
    ->setDbPassword('db_password')
    ->

  SimpleBackup::start()
    ->setDbName('db_name')
    ->setDbUser('db_username')
    ->setDbPassword('db_password')
    ->excludeOnly(['users', 'posts'])
    ->then()->storeAfterExportTo('backups')
    ->then()->getResponse();



use Coderatio\SimpleBackup\SimpleBackup;

// Set the database to backup
$simpleBackup = SimpleBackup::setDatabase(['db_name', 'db_user', 'db_password', 'db_host'])
  ->storeAfterExportTo('pathtostore', 'file_name (optional)');

echo $simpleBackup->getExportedName();

/**
* @return object
**/
var_dump($simpleBackup->getResponse());



use Coderatio\SimpleBackup\SimpleBackup;

// Set the database to backup
$simpleBackup = SimpleBackup::setDatabase(['db_name', 'db_user', 'db_password', 'db_host'])
  ->downloadAfterExport($file_name (optional));

$tables = [
  'users' => 'is_active = true'
];

$simpleBackup->setTableConditions(array $tables);

$tables = [
  'users' => 50,
  'posts' => 50
]

$simpleBackup->setTableLimitsOn(array $tables);



use Coderatio\SimpleBackup\SimpleBackup;

// Set the database to backup
$simpleBackup = SimpleBackup::setDatabase(['db_name', 'db_user', 'db_password', 'db_host (optional)']])
    ->importFrom('pathtosql_file or sql_contents');

/**
* You can then dump the response like this. 
*
* @return object
**/
var_dump($simpleBackup->getResponse());