I would like to know, how can I use this script:
https://coursesweb.net/php-mysql/simple- ... atabase_s2
to make backup of specific tables and how to restore these specific tables? Do you have any examples code for this?
For example, in the code you provide on the website:
Code: Select all
//data for connecting to MySQL
$conn_data = ['host'=>'localhost', 'user'=>'user_name', 'pass'=>'password', 'dbname'=>'database_name'];
$lang ='en'; //indice of the "lang_...json" file with texts
$dir ='backup/'; //folder to store the ZIP archive with SQL backup
//set object of backupmysql class
include 'backupmysql.class.php';
$bk = new backupmysql($lang, $dir);
$bk->setMysql($conn_data); //set connection
$tables = $bk->getTables(); //get array with all the tables in database
//if no error
if($bk->error === false){
//if tables, creates the SQL backup of all the tables and saves it in ZIP archive (get succesful or error message)
$bk_sql = (count($tables) >0) ? $bk->saveBkZip($tables) :'No tables in database';
echo $bk_sql;
}
else echo $bk->error;
Code: Select all
//data for connecting to MySQL
$conn_data = ['host'=>'localhost', 'user'=>'root', 'pass'=>'', 'dbname'=>'test'];
$lang ='en'; //indice of the "lang_...json" file with texts
$dir ='wp-content/themes/TEST/backups'; //folder to store the ZIP archive with SQL backup
$bk = new backupmysql($lang, $dir);
$bk->setMysql($conn_data); //set connection
$important_tables = array('patients','patientrecords');
$tables = $bk->getSqlBackup($important_tables); //get array with all the tables in database
Code: Select all
//if no error
if($bk->error === false){
//if tables, creates the SQL backup of all the tables and saves it in ZIP archive (get succesful or error message)
$bk_sql = (count($tables) >0) ? $bk->saveBkZip($tables) :'No tables in database';
echo $bk_sql;
}
else echo $bk->error;
By the way, it is an excellent work.
Kind regards