Monday, January 28, 2013

how to take filesystem and mysql backup on shared hosting

Many people are using the shared hosting for hosting there site. When you want to take filesystem and mysql backup with zip format.

You can use my script. Create two php files and upload to server. Following script will compress your files and able to take mysql backup in gzip format. Before this create phpinfo.php file and add following code.

<?phpphpinfo();?>Get your server's "DOCUMENT_ROOT " and use in command variable.create backup.php file and add following lines.1<?php$Command = 'tar -czf /home/content/html/website.tgz /home/content/html';exec($Command, $output, $result);if($result > 0) {echo 'Command not executed. ';echo 'Error Details:'.$output;} else {echo 'Command executed sucesfully.';}?>

create mysqlbackup.php  file and add following lines.

<?php$Command = 'mysqldump -udbusername -pdbpassword -hyour_database_hostname databasename | gzip > databasename.gz';exec($Command, $output, $result);if($result > 0) {echo 'Command not executed. ';echo 'Error Details:'.$output;} else {echo 'Command executed sucesfully.';}?>

Source : digcms[dot]com

0 comments:

Post a Comment