Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 7 Dec 2018 08:35:10 +0100
From:      Matthias Petermann <matthias@petermann-it.de>
To:        freebsd-questions <freebsd-questions@freebsd.org>
Subject:   /sbin/dump: instant exit in case of disk full (instead of prompting for next volume)
Message-ID:  <6116a4e5-34d1-3823-dd5e-28c784083cf2@petermann-it.de>

next in thread | raw e-mail | index | archive | help
Hello,

I am using dump(8) to backup local filesystems to an USB drive. Is there 
an easy way to non-interactively exit dump in case of target disk full 
error?

Currently it issues two prompts:

   DUMP: Is the new volume mounted and ready to go?: ("yes" or "no") no
   DUMP: Do you want to abort?: ("yes" or "no") yes

before it exits with code 3, which I need for my wrapping shell script 
to properly react. I would like to have it exit immediately in this 
case, without further interaction.

One way I explored was by using expect (script below), but I rather 
would use exclusively tools from base and don't want to add extra 
complexity to my backup script.

In case there is no easy way currently, would it make sense to enhance 
dump to provide an option for non interactive mode?

Kind regards,
Matthias



#!/usr/bin/env expect

set timeout 43200
set result 0

spawn /sbin/dump -C16 -b64 -0au -h0 -f /mnt/test.dump /

expect {
   eof {
     exit $result
   }
   timeout {
     exit 1
   }
   "*DUMP: Is the new volume mounted and ready to go?:*" {
     send "no\r"
   }
}

expect {
   eof {
     exit $result
   }
   timeout {
     exit 1
   }
   "*DUMP: Do you want to abort?:*" {
     send "yes\r"
     set result 3
   }
}

expect {
   eof {
     exit $result
   }
   timeout {
     exit 1
   }
}

-- 
Matthias Petermann <matthias@petermann-it.de> | www.petermann-it.de
GnuPG: 0x5C3E6D75 | 5930 86EF 7965 2BBA 6572  C3D7 7B1D A3C3 5C3E 6D75



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?6116a4e5-34d1-3823-dd5e-28c784083cf2>