My wrapper-script for BorgBackup

I use the awesome tool borg for my backups. Although I really like most CLI tools, I always found the borg syntax quite hard to remember.
That's why I created this little bash-script that I use on all of my machines:

#!/usr/bin/env bash

# Borg repository

# Source files

if [ $1 == "init" ]; then
    borg init -e repokey $REPO
    exit 0

if [ $1 == "create" ]; then
    borg create  --progress "$REPO::$(date +"%y-%m-%d_%H-%M-%S")" $FILES
    exit 0

if [ $1 == "mount" ]; then
    mkdir -p ~/_borg
    borg mount $REPO ~/_borg
    exit 0

if [ $1 == "umount" ]; then
    borg umount ~/_borg
    rm -rf ~/_borg
    exit 0

if [ $1 == "list" ]; then
    borg list $REPO
    exit 0

echo "Invalid command: $1"
exit 1

After configuring both variables and running ./ init once, creating backups is as simple as typing ./ create.

The mount option is also quite useful as it allows to quickly restore files from the backup in case of an emergency.

For the version that I use on my cloud-servers, I added these two lines:

export BORG_RSH="sshpass -p <password> ssh -p 23 -l <username>"
export BORG_PASSPHRASE="<passphrase>"

This way, no password has to be entered manually and the backup can run fully automated e.g using cron:

$ sudo crontab -l
#Ansible: storagebox_backup
15 7,11,22 * * * /opt/ create

The risk of storing the password in plain text on the server, however, might be problematic for some use cases.