Register
It is currently Thu Nov 27, 2014 8:57 pm

Shell script for back and restore


All times are UTC - 6 hours


Post new topic Reply to topic  [ 5 posts ] 
Author Message
 PostPosted: Sun Aug 22, 2010 11:01 pm   

Joined: Sun Aug 22, 2010 10:54 pm
Posts: 4
Hi,

I have requirement on shell scripting. I require scripts for the following
1) Full backup(application and DB): tar all the files and database and copy them in the backup server
2) incremental back up of files: backup of all the updated files after the last backup
3) restoring of backup files: restore the backup files from the backup server to the application server

Please help me in providing the scripts.

Thanks in advance


Top
 Profile  
 PostPosted: Tue Aug 24, 2010 5:15 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
Hi,

Your request does not provide anywhere near the specification required to write the script so it's impossible to do reasonably, eg;

1) rsync -a /mydata backupserver:datastore
2) rsync --delete -a /mydata backupserver:datastore
3) rsync --delete -a backupserver:datastore /mydata

I suggest you actually use backup software;
http://www.google.co.uk/#q=linux+backup+software


Top
 Profile  
 PostPosted: Tue Aug 24, 2010 11:02 pm   

Joined: Sun Aug 22, 2010 10:54 pm
Posts: 4
Thanks for the reply

Buy i need to backup(both application files and MYSQL DB) and restore using shell scripting.

For Backup i need to tar all the files and DB and moved to the backup server/

For Restore i need to copy the backup files from the backup server to local sever.

For incremental backup i need to backup the files which are updated after the last backup

Please help me in providing the linux shell scripts for the above tasks

Thanks


Top
 Profile  
 PostPosted: Wed Aug 25, 2010 3:29 am   
Moderator
User avatar

Joined: Thu Oct 11, 2007 7:12 am
Posts: 229
Location: London - UK
Hi, sorry for the not really what you want to hear reply :)

Backing up mysql and app files to a tar file is reasonably easy, as is restoring them. However incremental backups into tar will be tricky. The script will likely either be complex or too basic and fiddly. If this is a school project or similar basic and fiddly would likely be ok heh.

Much *nux backup software will have command line access to it's functions and will be able to cope with mysql data and the propriety ones will likely also have incremental backups. I doubt very much that you're going to get incremental backups to tar using a script written here for free, I certainly do not have the time, sorry.
If someone else does that's great, indeed they could then publish it to a website under GPL and everyone could use it...oh yeah several people already have and they're searchable for on google :)

The following are some basic pointers, if you wish to have a go at writing it yourself I'll attempt to help with problems you encounter.

You can use mysqldump to backup mysql data;
http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html

You can restore mysql data using the dumped backup and piping it into mysql client similar to this;
mysql < backup.sql

To tar files up;
cd /path/to/app/
tar czf backup.tgz files/

To restore the tar files;
cd /path/to/app/
tar xzf backup.tgz

To copy to another server;
scp backup.tgz my.backup.server:/backup/location/


Top
 Profile  
 PostPosted: Sun Sep 05, 2010 11:54 pm   

Joined: Sun Aug 22, 2010 10:54 pm
Posts: 4
I have created a script file to dump the application files using the following script

Code
=============
#!/bin/bash
#Full Day Backup Script
#application folders backup

now=$(date +"%d-%m-%Y")
#use 1 instead of 0 which is incremental backup
dump -0f $now /var/www/html/*
=============

using this we can successfully dumped the application files.

Now i want to restore the dumpfile

How can i restore using shell script?

please help

Thanx in advance


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP