Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have made two shell scripts

Script 1: It does all Home directory backups with name


Script 2: It does SQL backups of all sites every 3 hrs.


Now currently if I want to restore the site, I have to copy the tar file to


and then untar there with all the permissions as well and then manually import the database.

Is there any way (for instance a program, system or script) that I can just select which backup I want to restore and do automatically?

Maybe like a cPanel addon thing.

share|improve this question

closed as off-topic by HopelessN00b, Ward, MadHatter, Tim Brigham, kasperd Feb 25 at 16:13

This question appears to be off-topic. The users who voted to close gave these specific reasons:

If this question can be reworded to fit the rules in the help center, please edit the question.

Hey Mirage, hope you don't take offense to me editing your posts this evening. I'm just lookin' out for you. Trying to make things a little clearer, clean up spelling and punctuation and make it more likely that people will pay attention to your post. – Wesley Mar 9 '10 at 2:34
sorry for that , i will take care in future. Actually i was in the hurry to post questions :) – John Mar 9 '10 at 4:41
up vote 1 down vote accepted

The script you write, which could be as simple as:

zcat username_database_date.sql.gz | mysql

Depending upon how you dumped the database(s), you might have to drop before sourcing the file. Be careful.

share|improve this answer
IS it possible to to make a webpage for that so that it shows all backups in dropdown list and i click restore. But all restore is done at background by shell.Is this possible – John Mar 9 '10 at 4:43
It is technically possible, yes. I cannot recommend a pre-existing solution for cpanel. – Warner Mar 9 '10 at 5:28
It doesn't necessarily be a capnel. If that possbile i can make a php page on main domain name and from there i can restrore backups. Can i use shell commands inside php language – John Mar 9 '10 at 5:43
You can make system calls from PHP using the system() function. Be aware though that a web page will be run as apache so may not and should not have permissions do do what you require. Alternatively you could get a PHP script to set a trigger such as add the job to a MySQL table, that a user with permissions to run the job can check from a cron script if there are any jobs in the table and process them. Just take you time and think about the security implications as you do this. – Richard Holloway Mar 9 '10 at 14:28

If you are willing to let go of your script-based backup system, take a look at BackupPC. It can easily restore files. Databases have to be restored some other way though.

share|improve this answer