LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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, 04:32 AM   #1
glennbtn
Member
 
Registered: Dec 2009
Posts: 151

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, 04:44 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,629

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
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, 07:19 AM   #3
scinerd
LQ Newbie
 
Registered: Jan 2005
Location: usa
Distribution: Ubuntu, Centos
Posts: 16

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, 07:25 AM   #4
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,629

Rep: Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265Reputation: 7265
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, 08: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 12:42 PM.
 
Old 03-27-2013, 12:05 PM   #6
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
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 11:43 AM
[SOLVED] rsync execution issue with crontab - Have given full path to rsync too!! Prabagaran Linux - Server 6 04-15-2011 01:39 AM
LXer: Backup with rsync and rsync.net LXer Syndicated Linux News 0 09-14-2010 04:20 PM
rsync server backup through ssh tunnel issue vidhut Linux - Networking 1 01-06-2009 03:53 AM
Using RSync to backup a secondary off-site backup server pezdspencer Linux - Software 4 06-29-2007 03:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:40 AM.

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