LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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
  Search this Thread
Old 03-27-2013, 05:32 AM   #1
glennbtn
Member
 
Registered: Dec 2009
Posts: 96

Rep: Reputation: 18
Rsync backup issue


Hi All

I have a usb drive setup on a customer Ubuntu server for backups. The backup drive also accepts rsync backups from another 2 servers on the same box.

The issue I have is that sometimes the users forget to plug the usb drive on the server. When this is done it backs up straight to the created mount point created for the usb drive and fills the hard drive up.

IS there anyway in my bash script I can stop the rsync happening if the usb drive is not actually attached rather than it using the mount point (if i have explained it correctly)

Thanks

Glenn
 
Old 03-27-2013, 05:44 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
you would need to write a script to check it (before backup), rsync has no built-in features to perform such checks.
 
Old 03-27-2013, 08:19 AM   #3
scinerd
LQ Newbie
 
Registered: Jan 2005
Location: usa
Distribution: fedora mostly
Posts: 15

Rep: Reputation: 0
I usually use a local mount point and open a log file before I start the rsync. I track how long it takes to run my backups but it also gives me a way to confirm the mount point is there. If the mount point is remote you could test it like this

ssh <remote host> "test -f /mount/point/somefile" || exit
 
Old 03-27-2013, 08:25 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian i686 (solaris)
Posts: 8,104

Rep: Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267Reputation: 2267
Quote:
Originally Posted by scinerd View Post
ssh <remote host> "test -f /mount/point/somefile" || exit
Sorry, but it does not work. Usually it is ok, but /mount/point/somefile may exist anyway (either device is mounted or not).
Much better would be to check if it is really mounted:
mount | grep <mount point pattern>
 
Old 03-27-2013, 09:22 AM   #5
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286
You can first detect the device using lsusb or similar cmd, and add it to your script becfore it runs rsync, like:
Code:
lsusb | grep 'usb'
if [[ $? -eq 0 ]]; then
rsync <options>
else
echo "No usb found, thus exiting"
fi

Last edited by shivaa; 03-27-2013 at 01:42 PM.
 
Old 03-27-2013, 01:05 PM   #6
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora
Posts: 2,630

Rep: Reputation: 495Reputation: 495Reputation: 495Reputation: 495Reputation: 495
label the USB device as something like USB_BACKUP or some other easy to identify label, then just scan for the label before the backup script starts. if the label is not found, the backup fails, if it is found then it proceeds as normal.
 
  


Reply


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Rsync Backup for Windows, Linux Knoppix, and Other Smart Technologies in Handy Backup by Novos LXer Syndicated Linux News 0 12-24-2011 12:43 PM
[SOLVED] rsync execution issue with crontab - Have given full path to rsync too!! Prabagaran Linux - Server 6 04-15-2011 02:39 AM
LXer: Backup with rsync and rsync.net LXer Syndicated Linux News 0 09-14-2010 05:20 PM
rsync server backup through ssh tunnel issue vidhut Linux - Networking 1 01-06-2009 04:53 AM
Using RSync to backup a secondary off-site backup server pezdspencer Linux - Software 4 06-29-2007 04:40 PM


All times are GMT -5. The time now is 03:53 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration