#!/bin/sh

# Copyright C 2002-2003 by Isilon Systems, Inc. All rights not expressly
# granted herein are reserved.
# Created in the United States of America.
# 
# This digital media is protected by U.S. and international copyright and
# intellectual property laws. Unless otherwise specified, all information
# and screens appearing as part of this digital medium, including
# software, services, documents, text, images, icons, and logos design;
# the selection, assembly, arrangement, and design thereof; and the code
# that enables its presentation, are the sole property of Isilon Systems,
# Inc.
# 
# Except as otherwise required by applicable law, no part of any
# copyrighted material may be reproduced, modified, translated,
# distributed, published, or transmitted by any means, electronic or
# mechanical, for any purpose, without the prior written consent of Isilon
# Systems. 
#  
# Isilon and Isilon Systems are registered trademarks of Isilon Systems,
# Inc.  Legion is a trademark of Isilon Systems, Inc.  All other
# trademarks and registered trademarks are the property of their
# respective holders.

# isi_backup_winbind
#
# This file takes the file /ifs/.ifsvar/winbindd_imap.tdb and creates
# a compressed file in /var/backup.  This script is meant to be called
# on a daily basis from cron.

SOURCEFILE=/ifs/.ifsvar/winbindd_idmap.tdb
TARGETDIR=/var/backup
PIDFILE=/var/run/isi_backup_winbind.pid

WORKFILE=`basename $SOURCEFILE`

# Make sure it's not already running
if [ -f $PIDFILE ] ; then
	exit 0
fi

echo $$ > $PIDFILE

# Check if ifs is mounted
/sbin/mount -p -t efs | grep efs 2>&1 >> /dev/null
if [ ! $? -eq 0 ] ;  then
	rm -f $PIDFILE
	exit 0
fi

# check if the file we're backing up and the destination directory are
# present
if [ ! -e $SOURCEFILE ]; then
	rm -f $PIDFILE
	exit 0
fi

if [ ! -e $TARGETDIR ]; then
	mkdir -p $TARGETDIR
fi

# back it up!
/usr/bin/gzip -c $SOURCEFILE > $TARGETDIR/$WORKFILE.gz

# clean up
rm -f $PIDFILE
