Backup and restore mysql database using php script
Perform simple and fast MySQL backup/restore using PHP. You can use it to dump a full database or only some tables. It requires PHP 5.0.5 or later. More information: Using PHP to backup MySQL databases Backup:
Simply upload myphp-backup.php script to the DocumentRoot directory of your web application via FTP or other method and run it accessing http://www.example.com/myphp-backup.php. You can also run it from command line. Don't forget to set your database access credentials before performing any backup editing these lines from myphp-backup.php script: By default backup files will be called myphp-backup-{DB_NAME}-YYYYmmdd-HHMMSS.sql.gz and stored in myphp-backup-files subdirectory. Example output backup file:
Restore: Upload myphp-restore.php script to your DocumentRoot directory and your backup file to a subdirectory called myphp-backup-files. Then simply run the script accessing http://www.example.com/myphp-restore.php or from command line. You can change the backup filename and subdirectory editing these lines. Don't forget to set your user credentials too!
Project at GitHub: https://github.com/daniloaz/myphp-backup (c) Daniel López Azaña, 2012-2017 (http://www.daniloaz.com) Back up And Restore With PHPToday I’m going to share with you a very useful script that can create backup of your mysql database and restore it any time you wanted, just as one click recovery of mysql using a php script . I need to make it because one of my client need this feature in his admin panel So here are the steps to use it. it take just 5 second for backup and 5 second to restore Here are some steps you need to take 1. Create an object of class backup_restore [php]$obj = new backup_restore(‘hostname’,’db_name’,’user’,’paswd’,’*’);[/php] 2. If you want to create backup of your mysql database ,call backup function [php]$message = $obj–>backup();[/php] 3. If you want to restore your database,call restore function. [php]$message = $obj–>restore();[/php] 4. That’s it rest of thing ,code will tell you. Don’t forget to change argument ‘hostname‘ change to ‘your hostname‘. ‘db_name’ change to your database name. ‘username’ change to’ ‘ MySQL username‘. ‘password‘ change to ‘MySQL password‘. ‘path’ is an option argument if you want to store sql dump in a secure location otherwise sql dump will be generated in current directory [NEW ADDED] ‘*’ Change to table name whose backup you want. [ARGUMENT OMITTED] New Added Feature
Instruction and feature: 1. The file this script generate is pure sql file .so you can import it by phpmyadmin. 2. Can handle large db back and restore. 3. Support cms backup. wordpress, joomla, drupal and all others. 4. It does not use mysqldump command ,As many server do not enable shell_exec. 5. It gives 100% sql file. 6. 5-sec for backup and 5-sec for restoration 7.Open Source : Download –> Use –> Improve –> Share . No Warranty.:) Download script belowzip contain class and example file Download it free from github Download Thank you |