Need suggestions on a backup issue

July 20th, 2012 - 12:00 pm ET by Paul E Condon | Report spam
I was bitten by a bug in my backup system recently and would like
advice on how to fix the problem. I use Bash scripts and crontab to do
a daily backup each morning at 6:25 AM. (Why then? Because it is the
default time set up by Debian on a new install, and I've never seen a
reason to change it.) The script runs on a computer that is separate
from my main desktop computer and also serves a print and apt cache
server. The script writes the backup directly on to a USB drive that I
keep plugged into the computer, and uses rsync to only write backup of
files that are new or have changed. Occasionally, I swap out the USB
drive with an alternative one and keep the swapped out one in a safe
place. I had thought the system was working fine until a few days ago
when this backup computer ran out of disk space on its root partition
and crashed. (The root partition is 20GB and the system files use 3GB
of it.) The cause of the crash was some how the USB drive had become
umounted and the daily backup script filled the root partition with an
attempt to backup all 100GB of stuff on the main desktop computer.

Debian already provides an email facility that allows cron scripts to
email me with error messages. I need a way to test in Bash whether, or
not, there actually is a disk mounted at /media/wdp8.

What test can I code in Bash to determine that there is no disk
mounted at this mount point? I'm thinking of testing for the
presence of the file lost+found, but is there something better?

Thanks
Paul E Condon
pecondon@mesanetworks.net


To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: http://lists.debian.org/20120720155053.GA2231@big.lan.gnu
email Follow the discussionReplies 7 repliesReplies Make a reply

Similar topics

Replies

#1 Darac Marjal
July 20th, 2012 - 12:10 pm ET | Report spam

On Fri, Jul 20, 2012 at 09:50:53AM -0600, Paul E Condon wrote:



[cut]
What test can I code in Bash to determine that there is no disk
mounted at this mount point? I'm thinking of testing for the
presence of the file lost+found, but is there something better?



Two points.

1. See if "man mountpoint" is suitable

2. Don't re-invent the wheel. There are plenty of people who've solved
the "backup to a USB disk" before you. Some of their work is in debian.






To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Archive: http://lists.debian.org/
Replies Reply to this message
#2 Camale
July 20th, 2012 - 12:20 pm ET | Report spam
On Fri, 20 Jul 2012 09:50:53 -0600, Paul E Condon wrote:

(...)

What test can I code in Bash to determine that there is no disk mounted
at this mount point? I'm thinking of testing for the presence of the
file lost+found, but is there something better?



Check if any of these tips help:

http://stackoverflow.com/questions/...-with-bash

Greetings,

Camaleón


To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Archive: http://lists.debian.org/juc03v$10r$
Replies Reply to this message
#3 Rob Owens
July 20th, 2012 - 12:30 pm ET | Report spam
On Fri, Jul 20, 2012 at 09:50:53AM -0600, Paul E Condon wrote:

Debian already provides an email facility that allows cron scripts to
email me with error messages. I need a way to test in Bash whether, or
not, there actually is a disk mounted at /media/wdp8.

What test can I code in Bash to determine that there is no disk
mounted at this mount point? I'm thinking of testing for the
presence of the file lost+found, but is there something better?



Rather than looking for lost+found (which could be any disk), I'd look
for an identification file that you put on that disk. For instance,
/media/wdp8/.backupdrive1

I guess you could also grep /etc/mtab for /media/wdp8, but I'm not sure
if that's 100% reliable.

-Rob


To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Archive: http://lists.debian.org/
Replies Reply to this message
#4 Tixy
July 20th, 2012 - 02:10 pm ET | Report spam
On Fri, 2012-07-20 at 09:50 -0600, Paul E Condon wrote:
I need a way to test in Bash whether, or
not, there actually is a disk mounted at /media/wdp8.



A bit hacky, but what I do in my backup scripts is...

if mount | grep -q " /media/wdp8 "
then
...
fi

Tixy


To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Archive: http://lists.debian.org/
Replies Reply to this message
#5 Dan Ritter
July 20th, 2012 - 02:50 pm ET | Report spam
On Fri, Jul 20, 2012 at 07:04:35PM +0100, Tixy wrote:
On Fri, 2012-07-20 at 09:50 -0600, Paul E Condon wrote:
> I need a way to test in Bash whether, or
> not, there actually is a disk mounted at /media/wdp8.

A bit hacky, but what I do in my backup scripts is...

if mount | grep -q " /media/wdp8 "
then
...
fi



One other suggestion:

If you mount a backup drive on /media/wdp8/, have your backup
program start writing to /media/wdp8/backup/, a dir that exists
on the drive but not on your underlying filesystem.

If the directory doesn't exist, it ought to exit with an
appropriate error rather than filling your root filesystem.

-dsr-


To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact
Archive: http://lists.debian.org/
Replies Reply to this message
Help Create a new topicNext page Replies Make a reply
Search Make your own search