-[ -d $backupdir ] || mkdir -p $backupdir
-[ -d $backupdir ] || fatal "Backup directory '$backupdir'"
+# If needed, make sure that the specified vserver exists and is running.
+if [ $usevserver ]
+then
+ debug "Examining vserver '$vsname'"
+ # does it exist ?
+ vroot="$VROOTDIR/$vsname"
+ [ -d $vroot ] || fatal "vserver '$vsname' does not exist at '$vroot'"
+ # is it running ?
+ $VSERVERINFO -q $vsname RUNNING
+ if [ $? -ne 0 ]
+ then
+ fatal "vserver $vsname is not running."
+ fi
+fi
+
+## Prepare ignore part of the command
+## This only works for mysqldump at the moment
+
+ignore=''
+for i in $ignores; do
+ ignore="$ignore --ignore-table=$i"
+done
+
+# create backup dirs, $vroot will be empty if no vsname was specified
+# and we will instead proceed to operate on the host
+[ -d $vroot$backupdir ] || mkdir -p $vroot$backupdir
+[ -d $vroot$backupdir ] || fatal "Backup directory '$vroot$backupdir'"