dotfiles/.local/bin/make-backup

22 lines
539 B
Bash
Executable file

#! /usr/bin/sh
export BORG_REPO="/media/backup/"
export BORG_PASSCOMMAND="cat ${HOME}/.keys/borg-passphrase.txt"
TS_DIR="${HOME}/.local/state/backup"
mkdir -p "${TS_DIR}"
backup () {
target=$1
directory=$2
if "${HOME}/.local/bin/dirtree-changed" --directory "${directory}" --check-file "${TS_DIR}/${target}"
then
borg create --compression auto,lzma ::"${target}"-{now} "${directory}"
touch "${TS_DIR}/${target}"
fi
}
backup circuits "${HOME}/.config/circuits"
backup documents "${HOME}/Documents"