LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 07-16-2006, 06:41 PM   #1
RodWC
Member
 
Registered: Oct 2005
Distribution: SolydK, Linux Mint KDE, Debian
Posts: 180

Rep: Reputation: 30
automatic rsync mirroring fears


I have a server with rsync running nightly as a cron job to backup/mirror one disk to another, ie:
Code:
rsync -au /mnt/Disk-1 /mnt/Disk-3/Disk-1_backup
This works fine, but I'd like to add the --delete option so I wouldn't have to do that manually. The reason I haven't done it is fairly simple: if something happens to "Disk-1", and it becomes unmounted (perhaps unmountable), all that mirrored data will be erased from "Disk-3", and the backup will have done me no good. Is there a way to use the --delete option, but keep it from running if "Disk-1" would not be mounted?

Thanks
 
Old 07-16-2006, 06:55 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
This should do it:

Code:
DISK1=`/bin/mount | /bin/grep "Disk-1"`
if [ "$DISK1" == "" ]
then
   echo "Disk-1 not mounted, rsync skipped"
else
   rsync -au /mnt/Disk-1 /mnt/Disk-3/Disk-1_backup
fi
 
Old 07-16-2006, 07:03 PM   #3
nattflyger
LQ Newbie
 
Registered: Jul 2006
Posts: 6

Rep: Reputation: 0
My setup is similar, I back up a remote SMB share using rsync. I got the solution to this problem from Vector Linux's Support Forum. The backup is launced from a script:

##! /bin/bash
entries="$(ls -A "/share_source")"
if [ -z "$entries" ]
then
echo "Network connection to server lost. Backup aborted" > /error_file
else

rsync -avub --delete /share_source /share_destination
 
Old 07-17-2006, 12:04 AM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
I think the mount-based one would work better on the event you need to have a new disk for the remote site or something similar.

If you have the space, you could keep 2 (alternating) copies on the backup server, so even if one gets blown away, the other would still be good.
 
  


Reply



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
rsync mirroring with SSH dlublink Linux - Networking 2 05-03-2006 08:18 AM
Server mirroring ? rsync Bluesuperman Linux - Networking 3 04-25-2006 10:12 PM
Automatic rsync restart when dynamic IP changes joma Slackware 6 04-19-2006 05:50 AM
Installation fears p1p Mandriva 9 03-24-2004 06:49 AM
Mirroring servers using RSYNC RKris Linux - Networking 1 05-15-2003 06:26 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:28 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration