DSL Ideas and Suggestions :: Not backing up to a bad device



If you enter a non-existent device name in the backup/restore widget, backup/restore fails but the garbage name gets stored in /opt/.backup_device anyway.

If you forget and reboot, the automated backup from powerdown.sh tries to backup to this non-existent device and fails --> work lost.

One fix is to:

1. Test for a bad device name at the beginning of filetool.sh (eg)
Code Sample

# Get the device name from argument $3 or  /opt/.backup_device
DEVICE="$3" || DEVICE="$(cat /opt/.backup_device 2>/dev/null)"

# Exit if no device specified or if DEVICE is not a valid block device
[ "x$DEVICE" = x  -o ! -b "/dev/$DEVICE" ] && exit 1


2. Change filetool.sh so that it only stores the device name if backup/restore is successful eg a "clean-up" function including:
Code Sample

# Only store device name if backup/restore successful
[ $1 -eq 0 ] && echo $(basename $DEVICE) >/opt/.backup_device
# Remove password file if decryption fails
[ $1 -eq 98 ] && rm -f /etc/sysconfig/des


3. Remove the write to /opt/.backup_device from dsl-restore.sh. Also, filetool.sh can do the mount test on the device name etc

4. filetool.lua can then be simplified:
Code Sample

  w = Window{320,75, "Filetool"}
  input = Input{60,10,210,25,"Device:"}
  readfrom("/opt/.backup_device")
  input.value = read()

  cancel = Button{60,40,70,25,"&Cancel"}
  function cancel:callback()
    exit(0)
  end

  backup = Button{130,40,70,25,"&Backup"}
  function backup:callback()
t = {"filetool.sh backup noprompt ".. input.value}
call(execute, t)
exit(0)
  end
 
  [ and ditto for the restore function ]
 
  etc

 
I tried these ideas in the updated fast backup scripts posted
here today.
(lzop does not have to be used)


original here.