BackupPC-users

Re: [BackupPC-users] Two external disks change: best practice and scripts

2008-12-17 02:59:46
Subject: Re: [BackupPC-users] Two external disks change: best practice and scripts
From: Les Stott <les AT cyberpro.com DOT au>
To: "General list for user discussion, questions and support" <backuppc-users AT lists.sourceforge DOT net>
Date: Wed, 17 Dec 2008 18:57:39 +1100
Ermanno Novali wrote:
If you like i can post the changed init script (redhat/centos based).

Hope that helps.

Regards,

Les

Very helpful,
i think i'll try out soon your method
if you like post your modified init script,
thank you!
The script is attached.

Its also in the mailing list archives....

http://www.mail-archive.com/backuppc-users AT lists.sourceforge DOT 
net/msg09961.html

It may not be the prettiest way to do it, but it does work ;)

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 $?
------------------------------------------------------------------------------
SF.Net email is Sponsored by MIX09, March 18-20, 2009 in Las Vegas, Nevada.
The future of the web can't happen without you.  Join us at MIX09 to help
pave the way to the Next Web now. Learn more and register at
http://ad.doubleclick.net/clk;208669438;13503038;i?http://2009.visitmix.com/
_______________________________________________
BackupPC-users mailing list
BackupPC-users AT lists.sourceforge DOT net
List:    https://lists.sourceforge.net/lists/listinfo/backuppc-users
Wiki:    http://backuppc.wiki.sourceforge.net
Project: http://backuppc.sourceforge.net/
<Prev in Thread] Current Thread [Next in Thread>