All countries
44,234,933
Covid-19 Statistic
Updated on October 28, 2020 1:32 am
Wednesday, October 28, 2020

Auto Backup Database Mysql Menggunakan PHP

Popular

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

How to Watch Roald Dahl’s The Witches Full Online: Trailer, Start Date & More

Watch Roald Dahl's The Witches Full Movie In late 1967, a young orphaned boy goes to live with his loving grandma in the rural Alabama town of Demopolis. As the boy and his grandmother encounter some deceptively glamorous but thoroughly diabolical witches, she wisely whisks him away to a seaside resort. Regrettably, they arrive at precisely the same time that the world's Grand High Witch has gathered her fellow cronies from around the globe -- under cover -- to carry out her nefarious plans.

Blood of Zeus ‘S1/E1’ Season 1 episode 1 Release Date, Watch Online

Are you ready for an all-new episode of Blood of Zeus tonight? Below is all you need to know so you can keep up...

This Is Us ‘S5/E1’ Season 5 episode 1 Release Date, Watch Online

Are you ready for an all-new episode of This Is Us tonight? Below is all you need to know so you can keep up...

We Are Who We Are ‘S1/E7’ Season 1 episode 7 Release Date, Watch Online

Are you ready for an all-new episode of We Are Who We Are tonight? Below is all you need to know so you can...

Chicago Bears vs. Los Angeles Rams | NFL Week 7 Game

Chicago Bears vs. Los Angeles Rams | NFL Week 7 Game Preview #NFL #Football #AmericanFootball About NFL on CBS NFL on CBS is in its 60th season...