The shell destination type enables the use of external storage not natively supported by HashBackup, where sending, getting, and removing files can be done via a Unix command or shell script. Shell destinations can be written in any language.
Shell destinations report success or failure with their exit code. If a non-zero exit code is returned (failure), the command is retried with exponential backoff like all other destinations.
To make parsing easier, consider adding a
--command option to
the end of the
run keyword value. The command line is processed by
the regular Unix shell, so things like
$VAR, shell functions, and
quoting work fine.
To avoid errors on the first backup, give the command:
to all shell destinations before the first backup.
HB adds a command and arguments to the end of the
run command line.
Below are the commands HB sends and the shell destination’s
Exit with status 0 if the destination is available. This is used once per worker during startup.
send pathname filename
Send the local file
pathname to the remote destination and store it
filename. The file may already exist on the remote, and HB
send to overwrite the existing file. This happens for
dest.db. The file size may stay the same
DESTID), so don’t use file size as an indication of
whether to copy a file; the file should be unconditionally copied.
Some protocols like rsync automatically prevent partial files on the
remote by copying first into a temp file then renaming the temp file
to the real filename. If your remote protocol doesn’t do this
automatically (ftp doesn’t for example), it’s a good idea to send the
filename.tmp, then rename
filename if it already exists. If the remote cannot
rename over an existing file, you can send as
filename, then rename
filename. This runs the
slight risk of a failure after the delete, which will be corrected
automatically on the next backup by resending the file.
get pathname filename
Fetch the remote file
filename and store it in the local file
Pathname will not exist on the first get attempt, but
may exist on a retry. This can be used to do a restart, or
can be deleted or completely overwritten to start over.
Remove the remote file
filename. If it doesn’t exist, no error
should occur. If the
send command creates
renames it, both
filename.tmp should be removed on
destname mydest type shell run python /home/jim/iface.py --host blah.com --port 81 --cred /home/jim/iface.cred --destname mydest