37 lines
651 B
Bash
37 lines
651 B
Bash
#!/bin/bash
|
|
|
|
TYPE=$1
|
|
RETENTION=$2
|
|
# parameters passed by backuppc
|
|
|
|
BACKUP_DIR=/var/lib/ipa/backup
|
|
|
|
if [ $RETENTION = '' ]
|
|
then
|
|
RETENTION=2
|
|
fi
|
|
|
|
cd $BACKUP_DIR
|
|
|
|
# delete older ipa backups by counting fulls into account
|
|
OLDERFULL=`ls -1trd ipa-full-* | tail -$RETENTION | head -1`
|
|
|
|
TODELETE=`find . -maxdepth 1 -type d -name 'ipa-*' ! -newer $OLDERFULL | grep -v $OLDERFULL | tr '\n' ' '`
|
|
|
|
for i in $TODELETE
|
|
do
|
|
rm -rfv $i
|
|
done
|
|
|
|
# execute full ipa backup with a full backuppc backup
|
|
if [ $TYPE = 'full' ]
|
|
then
|
|
ipa-backup
|
|
elif [ $TYPE = 'incr' ]
|
|
then
|
|
ipa-backup --data --online
|
|
else
|
|
echo "first parameter (type) must be full or incr"
|
|
fi
|
|
|