#!/bin/bash
#
#   Simple Backup - service file used by cron/anacron
#
#   Copyright (c)2010: Jean-Peer Lorenz <peer.loz@gmx.net>
#   Copyright (c)2007: Ouattara Oumar Aziz <wattazoum@gmail.com>
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#


#   Do not call this file manually.


PATH=/usr/local/bin:/usr/bin:/bin
logdir=/var/log/sbackup
logfile=$logdir/sbackup-cron.log


if ! [ -d $logdir ]; then
	mkdir -p $logdir
fi

if [ -x /usr/bin/nice ]; then
	nicecmd="/usr/bin/nice -n 19"
fi

# See ionice(1)
if [ -x /usr/bin/ionice ]; then
	#ionicecmd="/usr/bin/ionice -c 2 -n 7 -t"
	# option -t is not implement in Ubuntu Hardy
	ionicecmd="/usr/bin/ionice -c 3"
fi

if [ -x /usr/bin/sbackup ]; then
	$nicecmd $ionicecmd /usr/bin/sbackup > $logfile 2>&1
elif [ -x /usr/local/bin/sbackup ]; then
	$nicecmd $ionicecmd /usr/local/bin/sbackup > $logfile 2>&1
fi
