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 08-07-2009, 07:01 PM   #1
MurdinE
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Rep: Reputation: 0
Question Don't rsync to disconnected external drive


I run Debian Lenny and got a backup script in /etc/cron.daily that syncronizes files to an external harddrive.

The external drive is mounted using /etc/fstab to the /mnt/exthdd directory.

If the drive is unplugged/disconnected all the files is copied/synced to the real directory that is on the system drive instead of the virtual/mounted external drive (of course).

This is the line for the external drive in the /etc/fstab for curiousity. I mount using the external drives UUID number as it can have different device letters depending on connected devices etc.
UUID=C8585D27585D1592 /mnt/exthdd ntfs-3g rw,user,noauto,umask=0,nls=utf8 0 0

Is there a way for the batch script to verify if the external drive is mounted and only rsync in that case? Or is there some other solution so all files is not copied if the drive is disconnected/unmounted?
 
Old 08-07-2009, 07:23 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
The simplest way is probably to just use an "if" statement in the script, and test for the existence of "exthdd" in /etc/mtab.
Code:
if [ "$(grep 'exthdd' /etc/mtab)" ]; then

 <run script>

fi
 
Old 08-08-2009, 02:13 PM   #3
MurdinE
LQ Newbie
 
Registered: Aug 2009
Posts: 2

Original Poster
Rep: Reputation: 0
Ah, of course. That should work like a charm, will configure it tonight. Thanks a lot for the help!
 
  


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
SAMBA server with external USB trying to use rsync over SSH Iatros Linux - Newbie 2 02-24-2009 12:59 PM
ubuntu installed on external hard drive, can't startup without external hard drive. Vanostaajen Linux - Software 23 01-20-2009 09:59 AM
rsync+continue from disconnected file Niceman2005 Linux - General 2 08-07-2008 04:52 AM
external enclosure for an internal hard drive vs external USB hard drive powah Linux - Hardware 1 03-10-2006 09:03 AM
New Hardrive only seen when other drive disconnected juu801 Linux - Hardware 5 07-25-2005 12:22 PM

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

All times are GMT -5. The time now is 09:10 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