#!/bin/sh set -eu backup() { local db_file="${1}" shift 1 local bk_file= bk_file="${db_file}.$(TZ=UTC date '+%Y%m%dT%H%M%SZ')" bakdb "${db_file}" "${bk_file}" printf '%s.xz' "${bk_file}" return 0 } remote_copy() { local bk_file="${1}" local remote="${2}" shift 1 rsync -a "${bk_file}" "${remote}" return 0 } usage() { printf 'Usage: %s [@]:\n' "${0}" return 0 } main() { local db_file= local remote= if [ ${#} -ne 2 ]; then usage 1>&2 return 1 fi db_file="${1}" remote="${2}" shift 2 case "${remote}" in ?*':'*) ;; *) usage 1>&2 return 1 ;; esac remote_copy "$(backup "${db_file}")" "${remote}" return 0 } main "${@}"