-1

I have made two shell scripts

Script 1: It does all Home directory backups with name

 username_home_date.tar.gz

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

username_databse_date.sql.gz

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

/home/username

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.

Wesley
  • 32,690
  • 9
  • 82
  • 117
  • 1
    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 09 '10 at 02:34
  • sorry for that , i will take care in future. Actually i was in the hurry to post questions :) –  Mar 09 '10 at 04:41

2 Answers2

1

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.

Warner
  • 23,756
  • 2
  • 59
  • 69
  • 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 –  Mar 09 '10 at 04:43
  • It is technically possible, yes. I cannot recommend a pre-existing solution for cpanel. – Warner Mar 09 '10 at 05: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 –  Mar 09 '10 at 05: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 09 '10 at 14:28
0

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.

ptman
  • 28,394
  • 2
  • 30
  • 45