LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
LinkBack Search this Thread
Old 03-26-2008, 10:25 AM   #1
crazy8
Member
 
Registered: Nov 2006
Posts: 132

Rep: Reputation: 15
Backup Script


I have a backup script here at work on a server that will backup whats needed from the server to an external drive. Now everything works great but there are a few things Id like to build into it but have no clue how. This isnt my script (its a past employees) all I have done is minor modifications as needed. The two things I would like to do is this...
This is after a full system backup has already been made nd will run once a day.
1) If a file gets deleted from the server then delete it from the external drive.
2) If a file is updated on the server then update on the external drive.
3) If possible perhaps alter the script to run something that ONLY updates the external (delete files or update them)as to what ever changes have been made to the server.

Is any of this possible and if so how could I do it. Like I said I have never done any kind of programming on linux or any heavy commands, so help on this would be greatly appreciated. Here is the script I have now to JUST run a back up.

mount /dev/sdb1 /mnt/backup
tar -cvf /mnt/backup/etc.tar etc
tar -cvf /mnt/backup/scooter.tar /u /var/www /d2a /etc /home /var/lib/mysql backup backup1
cp /data/* /mnt/backup
cp backup /mnt/backup
cp backup1 /mnt/backup

mount win2:/ /win2 -o rsize=1024,wsize=1024
tar -cvf /mnt/backup/win2.tar /win2/u /win2/var/www /win2/etc

df -H
ls -al /mnt/backup
umount /win2
df -H
umount /mnt/backup
echo
echo Done with Backup
echo
 
Old 03-26-2008, 10:40 AM   #2
mahmoud
Member
 
Registered: Apr 2006
Location: UK
Distribution: Mandriva, Debain, Redhat, Fedora, Ubuntu, FreeBSD
Posts: 269

Rep: Reputation: 30
all you really need is rsync it does wonders really
it synchronizes folders and files and if the is no changes it wont do anything
try
mount /dev/sdb1 /mnt/backup
rsync -vaz --delete --exclude="folder1" --exclude="folder2" /the/folder/ /destination/
exclude the folder u dont want to backup add what you want basically this is just a guide on
what you should use

Last edited by mahmoud; 03-26-2008 at 11:11 AM.
 
Old 03-26-2008, 10:44 AM   #3
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
Suggestion 1: Deal With Pieces

Aside from your stress level going up, this is one of the best ways to get involved. Assuming your being in a Linux forum this script is written in bash. So, I would suggest you need a bash scripting guide, regardless of your level of experience. O'Reilly's guide is good, and Linux Shell Scripting With Bash by Ken O. Burtch Prentice/Hall is pretty good, too.

I strongly suggest that you write stub code (a script or program that accomplishes one thing, as a teaching tool) to try out one idea, and then incorporate into the main script. If you start by tackling individual pieces and posting those questions, helping you could be managed better, IMHO. Let's take your deleting a currently deleted file from the backup drive.

Are you wanting to delete that file from a tar archive? I suppose it could be done by looking for the file using tar t; unpacking the tar file in a sandbox; deleting the file; and making a tar file of what's left.

Last edited by cmnorton; 03-26-2008 at 10:45 AM. Reason: spelling
 
Old 03-26-2008, 10:46 AM   #4
BashTin
Member
 
Registered: May 2003
Location: West Midlands, United Kingdom.
Distribution: Slackware 13.37
Posts: 247

Rep: Reputation: 32
Hi.

Not an expert by any means but I too have a backup script that basically updates a tar archive (removes deleted files, includes updated files, etc) then burns the whole image to DVD.

I believe what you are missing is rsync. This is the key to update/remove files from the archive.

Here is my script as it stands, hope it points you in the right direction...

Code:
##### rsync a=archive mode, x=one file system v=verbose ####
rsync -axv --delete --exclude-from=/home/mrt/documents/backup/exclude.txt /home/mrt/.kde/share/apps/kmail/mail /home/mrt/documents /etc/rc.d/rc.firewall /usr/local/etc/pdnsd.conf /etc/samba/smb.conf /etc/cups/cupsd.conf /bin/wipe /bin/daily-backup /bin/daily-backup2 /home/mrt/tmp 1> /home/mrt/documents/backup/backup.log

#### growisofs, front end to cdrecord adding dvd capabilities ####
#### -Z=initital data, -R=generate Rockridge extensions, joliet-long=generate joliet long extensions ####
#### -use-the-force-luke=tty=the only way to over write a dvd already containing data ####
/usr/local/bin/growisofs -Z  /dev/sr0 -use-the-force-luke=notray -use-the-force-luke=tty -use-the-force-luke=tracksize:1616633 -speed=4 -use-the-force-luke=bufsize:32m -R -joliet-long /home/mrt/tmp

#### clear up tmp file
rm -R -f /home/mrt/tmp
Hope that helps a little, BashTin
 
Old 03-26-2008, 11:07 AM   #5
bigrigdriver
LQ Addict
 
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,697

Rep: Reputation: 286Reputation: 286Reputation: 286
Your script will not accomplish 1) or 2) unless you include the means of extracting the archive, synching the files, and remaking the tar archive.

I respectfully suggest that before you go any further, do some homework in re backups. http://www.linux-backup.net/ is a good place to start reading.

When you have done the reading, then look over some extant applications for making network backups, which you can find at http://www.linux.org/apps/all/Admini...on/Backup.html.
 
Old 03-26-2008, 11:35 AM   #6
crazy8
Member
 
Registered: Nov 2006
Posts: 132

Original Poster
Rep: Reputation: 15
Wow thanks for all the replies. I will take a look into rsync along with the other suggestions. Thanks again.
feel free to post any other suggestions if there are others.

EDIT: I am running FC7 so from what I can tell (using "yum search rsync") rsync is already installed.
I will have to play with it and see what I can come up with

Last edited by crazy8; 03-26-2008 at 01:53 PM.
 
  


Reply

Tags
backup, rsync, tar


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Backup script rcmonroig Linux - Newbie 4 04-21-2007 12:58 AM
Backup script raptorman Programming 4 08-22-2005 09:52 AM
What backup script do you use? buldir Linux - Software 1 04-12-2005 02:57 PM
Need a backup script enygma Linux - General 5 11-04-2004 03:49 PM
backup script ixion Linux - Software 2 01-09-2003 06:39 AM


All times are GMT -5. The time now is 02:59 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration