Mauro Condarelli wrote:
Hi,
I asked this before, but no one answered, so I will try again :)
I am using a large (500G) external USB disk as backup media.
It performs reasonably, so no sweat.
Problem is:
Is there a way to do a pre-check to see if the drive is actually mounted
and, if not, just skip the scheduled backup?
It would be easy to put a do_not_backup file in the directory over which
I mount the remote.
I could then do a test to see if that file is present (no disk) or if it
is absent (something was mounted over it.
Unfortunately I have no idea where to put such a test in BackupPC!
Can someone help me, please?
Yes.
The way i do it in a usb drive scenario.......
Don't start backuppc at boot.
Schedule it via cron at the times you actually want it to run. I.e. do a
"service backuppc start" at say 10pm, then do a "service backuppc stop"
at 8am or so.
customize the init.d startup script for backuppc to mount the drives
before trying to start backuppc. if the drive fails the mount then don't
bother starting backuppc. When the stop command runs it unmounts the drive.
The init script can also send an email if there is a problem mounting
the drive.
Each drive will be configured as an ext3 filesystem, so your test to see
if its valid and mounted can be by looking for the "lost+found"
directory at the root of the drive.
That way then between 8am and 10pm you can hotplug the drives without
needing to unmount.
When you switch drives and start backuppc it just begins from scratch on
the new drive, or picks up where it left off from the last rotation.
Note: the new 3.1.0 series changes the order of tests when BackupPC
starts and it does a symlink test to see if it can create a link between
pc and cpool directories at the top level.
As you rotate in a new drive it will be empty and backuppc will fail to
start because it doesn't see the cpool or pc directory existing on the
filesystem.
This never happened before in 3.0.0 and i preferred that because it
meant i could just put an empty usb drive in and it would create the top
level tree of folders on the fly.
I posted on the list back in December.....
http://www.mail-archive.com/backuppc-users@lists.sourceforge.net/msg08103.html
....but got no response. I'd like to see the top level directories
created first, then do the symlink test.
a sample init script for a redhat based system which does this is
attached. It could be done better of course, no warranty use at your own
risk etc.
Related issue:
I would like to use a small pool of identical external HDs in order to
increase further security.
Aside from switching the disks round-robin with a certain time interval
(weekly?) is there anything else to be done to notify BackupPC it has a
new media to use? I guess not, but I would like someone to confirm this.
nothing really to do, BackupPC will carry on where the old drive left
off or start afresh on a blank drive.
Hope that helps.
Regards,
Les
#!/bin/sh
#
# DESCRIPTION
#
# Startup init script for BackupPC on Redhat linux.
#
# Distributed with BackupPC version 3.0.0, released 28 Jan 2007.
#
# chkconfig: - 91 35
# description: Starts and stops the BackupPC server
# Modified by Les Stott 19/3/07
# to suit automatically mounting and unmounting of an external usb drive
# when backuppc is installed on such a device.
MOUNTPOINT=/mnt/maxtor
DEVICE=/dev/sdc1
# Source function library.
if [ -f /etc/init.d/functions ] ; then
. /etc/init.d/functions
elif [ -f /etc/rc.d/init.d/functions ] ; then
. /etc/rc.d/init.d/functions
else
exit 0
fi
RETVAL=0
start() {
#
# You can set the SMB share password here is you wish. Otherwise
# you should put it in the config.pl script.
# If you put it here make sure this file has no read permissions
# for normal users! See the documentation for more information.
#
# Replace the daemon line below with this:
#
# daemon --user backuppc /usr/bin/env BPC_SMB_PASSWD=xxxxx \
# /usr/local/BackupPC/bin/BackupPC -d
#
echo -n "Mounting External Drive: "
mount $DEVICE $MOUNTPOINT 2> /tmp/mounted
RETVAL=$?
if [ "`grep -q "already mounted" /tmp/mounted ;echo $?`" = "0" ];then
RETVAL=0
fi
if [ "$RETVAL" = "0" ]; then
echo_success
chmod 775 $MOUNTPOINT
chgrp backuppc $MOUNTPOINT
echo ""
if [ -d "${MOUNTPOINT}/lost+found" ]; then
echo -n "Starting BackupPC: "
daemon --user backuppc /usr/local/BackupPC/bin/BackupPC -d
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/backuppc || \
RETVAL=1
return $RETVAL
else
echo "Possible Problem with mounted drive. No lost+found directory"
echo "to indicate filesystem."
echo -n "Starting BackupPC: "
echo_failure
echo "Possible Problem with mounted drive. No lost+found directory" |
mail -s"${HOSTNAME} Problem with BackupPC and External Drive Mount" root
echo ""
umount -f $DEVICE
exit 0
fi
else
echo_failure
echo ""
echo -n "Starting BackupPC: "
echo_failure
echo "Could not mount drive." | mail -s"${HOSTNAME} Problem with BackupPC
and External Drive Mount" root
echo ""
exit 0
fi
}
stop() {
echo -n "Shutting down BackupPC: "
killproc /usr/local/BackupPC/bin/BackupPC
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/backuppc
echo ""
echo -n "Unmounting Maxtor Drive: "
umount -f $DEVICE
if [ "$?" = "0" ]; then
echo_success
echo ""
else
echo_failure
echo ""
fi
return $RETVAL
}
restart() {
stop
start
}
reload() {
echo -n "Reloading config.pl file: "
killproc /usr/local/BackupPC/bin/BackupPC -HUP
RETVAL=$?
echo
return $RETVAL
}
rhstatus() {
status /usr/local/BackupPC/bin/BackupPC
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload)
reload
;;
status)
rhstatus
;;
*)
echo "Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit $?
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
BackupPC-users mailing list
BackupPC-users@lists.sourceforge.net
List: https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki: http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/