Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //backup database and save as zip.
- set_time_limit(1200);// increase time limit for large database
- $current_dir = 'db/';//folder where database file should be stored
- $host = HOSTA;//localhost
- $user = USERA;//database username
- $pass = PASSA;//database password
- $dbname1 = DATAA;//database name
- $time = time();
- $date = date("Ymd");
- $randi = rand();
- $sql_file_name = "$current_dir/db_backup_"."$randi"."_"."$date"."_$time"."."."sql";//use generated variable to avoid overwriting
- exec("C:\wamp\bin\mysql\mysql5.0.51b\bin\mysqldump.exe --user=$user --password=$pass --host=$host $dbname1 > $sql_file_name");//using mysqlidump.exe database dumping feature
- if (file_exists($sql_file_name)) {
- if(extension_loaded('zip')) {
- $zip = new ZipArchive(); // Load zip library
- $zip_name = "$sql_file_name.zip"; // Zip name
- if($zip->open($zip_name, ZIPARCHIVE::CREATE)==TRUE) {
- $zip->addFile($sql_file_name);
- $zip->close();
- //force user to download or save to a folder
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement