All countries
98,213,310
Covid-19 Statistic
Updated on January 22, 2021 2:45 pm
Friday, January 22, 2021

Auto Backup Database Mysql Menggunakan PHP

Popular

Terungkap Cara Pelaku Dapat Video Syur Mirip Gisel 19 Detik Sebelum Disebarkan di Medsos

Terungkap Cara Pelaku Dapat Video Syur Mirip Gisel 19 Detik Sebelum Disebarkan di Medsos - Setelah beredar luas dan viral video syur mirip artis...

Dominasi Netflix di Peta (Grafik Data) Saat ini Tidak Tersedia di China

Berdasarkan data yang kami miliki untuk 66 negara, kami menemukan bahwa Netflix adalah pemimpin pasar di 61 negara. Prime Video memimpin di Jerman, Austria dan India. BluTV memimpin di Turki dan iQiyi di Cina. Perhatikan bahwa Netflix saat ini tidak tersedia di China.

Eja Sutejahttp://Lambeteja.com
Hallo Gaes, Kenalin Nama Saya Suteja, Saya Kelahiran Kuningan Sekarang Domisili di Cirebon. Saya Berselancar Bebas Sambil Mencari Harta Karun, Kebetulan Saya Sangat Menyukai Dunia Sosialmedia untuk Mencari Pundi Pundi, Saya Berpengalaman hampir dari 2010.




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>



More articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest article

‘The Blacklist’ season 8 episode 3 – Release Date, Watch Online

The Blacklist Season 8 Episode 3 16 Ounces - Are you ready for an all-new episode of The Blacklist tonight? Below is all you...

‘The Stand’ season 1 episode 6 – Release Date, Watch Online

The Stand Season 1 Episode 6 The Vigil - Are you ready for an all-new episode of The Stand tonight? Below is all you...

‘WandaVision’ season 1 episode 3 – Release Date, Watch Online

WandaVision Season 1 Episode 3 Episode 3 - Are you ready for an all-new episode of WandaVision tonight? Below is all you need to...

‘The Good Doctor’ season 4 episode 7 – Release Date, Watch Online

The Good Doctor Season 4 Episode 7 The Uncertainty Principle - Are you ready for an all-new episode of The Good Doctor tonight? Below...

‘WandaVision’ season 1 episode 1 – Release Date, Watch Online

WandaVision Season 1 Episode 1 Episode 1 - Are you ready for an all-new episode of WandaVision tonight? Below is all you need to...