#!/bin/bash
#
# bpcdump
-# Copyright (C) 2008 by Titanium Mirror, Inc.
+# Copyright (C) 2008-2012 by Titanium Mirror, Inc.
# Author: R. Steve McKown <smckown@titaniummirror.com>
#
# Dumps the BPC VEID to external storage. It must have its storage on a
cleanup 1 "VEID private fs must be mounted to determine its size"
fi
-# Before we begin writing, remove old backup dirs until we have room
+# Before we begin writing, remove old backup dirs until we have room.
+# Other disk contents shall not be removed.
dstblks=$(df -P "$EXTFS" | grep "$EXTFS" | awk '{ print $4 }')
while [ $dstblks -le $srcblks ]; do
info "Only $dstblks free on $EXTFS"
oldest=$(cd $EXTFS && eval ls -td "ve${VEID}*" 2>/dev/null | tail -1)
- if [ -d "$EXTFS/$oldest" ]; then
+ if [ -z "$oldest" ]; then
+ cleanup 1 "out of space: need $srcblks KB, have $dstblks KB"
+ elif [ -d "$EXTFS/$oldest" ]; then
info "Removing old backup $oldest from $EXTFS"
rm -rf "$EXTFS/$oldest"
else