#!/usr/bin/env bash while getopts d:u:s:r:n:p: flag do case "${flag}" in d) bkp_dir=${OPTARG};; u) user=${OPTARG};; s) server=${OPTARG};; r) repository=${OPTARG};; n) backupname=${OPTARG};; p) port=${OPTARG};; esac done BORG_RSH='ssh -p ${port}' echo "Copy ssh priv key" mkdir $HOME/.ssh mkdir /logs cp /ssh_privKey $HOME/.ssh/id_rsa chown $(id -u):$(id -g) $HOME/.ssh/id_rsa ssh-keyscan -t rsa $SERVER >> ~/.ssh/known_hosts echo "Borg starting" echo $(date +%s) > /logs/starttime borg create -C lzma ${user}@${server}:${bkp_dir}${repository}::${backupname}_$(date -I'minutes') /backup exitCode=$? echo $(date +%s) > /logs/endtime