Langkah pertama teman-teman buat file dengan nama backup.php untuk membuat function backup seperti pada script di bawah ini.


while($row = $result->fetch_row()){
$tables[] = $row[0];
}
}else{
$tables = is_array($tables)?$tables:explode(',',$tables);
}
//Loop melalui Table
foreach($tables as $table){
$result = $db->query("SELECT * FROM $table");
$numColumns = $result->field_count;
$return .= "DROP TABLE $table;";
$result2 = $db->query("SHOW CREATE TABLE $table");
$row2 = $result2->fetch_row();
$return .= "\n\n".$row2[1].";\n\n";
for($i = 0; $i < $numColumns; $i++){ while($row = $result->fetch_row()){
$return .= "INSERT INTO $table VALUES(";
for($j=0; $j < $numColumns; $j++){
$row[$j] = addslashes($row[$j]);
$row[$j] = ereg_replace("\n","\\n",$row[$j]);
if (isset($row[$j])) { $return .= '"'.$row[$j].'"' ; } else { $return .= '""'; }
if ($j < ($numColumns-1)) { $return.= ','; }
}
$return .= ");\n";
}
}
$return .= "\n\n\n";
}
//simpan file , alamat penyimpanan dan nama file
$handle = fopen('backup/webbackup.sql','w+');
fwrite($handle,$return);
fclose($handle);
}

Jika sudah maka tahap selanjutnya teman-teman buat file dengan nama index.php yang berisi script untuk melooping function yang sudah di buat sebelumnya.


<script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>

<script>
function backupDatabaseTables(){
$.get("backup.php", function(){
})
setTimeout(backupDatabaseTables, 500000);
}
backupDatabaseTables();
</script>

CWR-CRB is circulated from all types of information that belongs to International, National news, States news, Bihar news, Sports news, Politics news, Business articles, Entertainment, Technology news, Health advise, Career opportunities etc.