Skip to content

Instantly share code, notes, and snippets.

@devuri
Forked from SahilC/Backup.php
Created January 28, 2018 04:13
Show Gist options
  • Save devuri/2d17b818fae01c079ab0a12af8106a83 to your computer and use it in GitHub Desktop.
Save devuri/2d17b818fae01c079ab0a12af8106a83 to your computer and use it in GitHub Desktop.
Php Mysql Database backup and restore
<?php
$dump_path = ""; //input location for the backup to be saved
$host = ""; //db host e.g.- localhost
$user = ""; //user e.g.-root
$pass = ""; //password
$command=$dump_path.'mysqldump -h '.$host.' -u '.$user.' bank > bank.sql';
system($command);
?>
<?php
$dump_path = ""; //your backup location
$host = ""; //host
$user = ""; //username
$pass = ""; /passwprd
$command=$dump_path.'mysql -h '.$host.' -u '.$user.' bank < bank.sql';
system($command);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment