Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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
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
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
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
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.