status="ok"
function make_backup() {
- vsname=$1
+ vsname="$1"
if [ -z "$vsname" ]; then
info "Running on host"
vdir=""
vexec="$VSERVER $vsname exec"
fi
- dumpdir=`interpolate "$backupdir" "$vsname"`
+ dumpdir="`interpolate "$backupdir" "$vsname"`"
info "Backing up to dir '$dumpdir'"
- [ -f $vdir$conf ] || fatal "slapd config file ($conf) not found"
- [ -d $dumpdir ] || mkdir -p $dumpdir
- [ -d $dumpdir ] || fatal "Backup directory '$dumpdir'"
+ [ -f "$vdir$conf" ] || fatal "slapd config file ($conf) not found"
+ [ -d "$dumpdir" ] || mkdir -p "$dumpdir"
+ [ -d "$dumpdir" ] || fatal "Backup directory '$dumpdir'"
dbsuffixes=(`@AWK@ 'BEGIN {OFS=":"} /[:space:]*^database[:space:]*\w*/ {db=$2}; /^[:space:]*suffix[:space:]*\w*/ {if (db=="bdb"||db=="hdb"||db="ldbm") print db,$2}' $vdir$conf|@SED@ -e 's/[" ]//g'`)
if [ "$ldif" == "yes" ]; then
if [ "$databases" == 'all' ]; then
- dbcount=`grep '^database' $vdir$conf | wc -l`
+ dbcount=`grep '^database' "$vdir$conf" | wc -l`
let "dbcount = dbcount - 1"
databases=`seq 0 $dbcount`;
fi
if [ "$compress" == "yes" ]; then
ext=".gz"
fi
- touch $dumpdir/$dbsuffix.ldif$ext
- if [ ! -f $dumpdir/$dbsuffix.ldif$ext ]; then
+ touch "$dumpdir/$dbsuffix.ldif$ext"
+ if [ ! -f "$dumpdir/$dbsuffix.ldif$ext" ]; then
fatal "Couldn't create ldif dump file: $dumpdir/$dbsuffix.ldif$ext"
fi
if [ "$compress" == "yes" ]; then
- execstr="$execstr | $GZIP > $dumpdir/$dbsuffix.ldif.gz"
+ execstr="$execstr | $GZIP > \"$dumpdir/$dbsuffix.ldif.gz\""
else
- execstr="$execstr > $dumpdir/$dbsuffix.ldif"
+ execstr="$execstr > \"$dumpdir/$dbsuffix.ldif\""
fi
# Run inside the vserver if needed
execstr="$vexec $execstr"
if [ $usevserver = yes ]; then
for vserver in $vsnames; do
- make_backup $vserver
+ make_backup "$vserver"
done
else
make_backup ""