Chapter 4. Developer's Guide to KBackup

KBackup can be extended by using a shell script (or any other executable) which will be started at three different points during the backup process. The idea behind it is to allow to mount, unmount, eject media in a system specific way, or do other things with the produced archive files.

The script to execute must be given with the --script command line option.

Here is a sample script:

Example 4.1.



case "$mode" in
 "slice_init" )
    if [ "$mountPoint" != "" ]
      mount /media/zip
      rm -f /media/zip/backup_2*.tar*

 "slice_closed" )

 "slice_finished" )
    if [ "$mountPoint" != "" ]
      umount /media/zip
      eject /media/zip

The script is always invoked with four command line arguments:

  • invocation mode

  • archive (slice) file name

  • target directory/URL

  • mountpoint of the target directory if it's a local directory, else an empty string

There are three possible invocation modes:

  • slice_init

    called before a new archive slice is being created on disc

  • slice_closed

    called after an archive slice has been created, but before it has been put into the target directory

    This can be used if you want to copy the archive slice to some additional place, e.g. the archive is sent to the main server (via a target URL), but you want to keep the last backup also onto the local disc.

  • slice_finished

    called after an archive slice has been successfully transferred into the target directory