systems/bin/localbak.sh
2024-08-05 08:11:36 -05:00

25 lines
571 B
Bash
Executable file

#!/usr/bin/env bash
#
# Create encrypted tarball and sync to remote
# requires: tar, gzip, age, rclone
# src: system/*, dst: bkp/*
# rclone target: preconfigured
#
# SPDX-License-Identifier: MIT
DTS=$(date "+%Y%m%d%H%M")
TGZ="bkp/syslocal-${DTS}.tgz"
TGT="remote:"
cd "${HOME}" || exit 1
[[ -d system ]] || exit 1
[[ -d bkp ]] || exit 1
echo "Creating ${TGZ} ..."
tar -czf "${TGZ}" system/*
echo "Encrypting ${TGZ} ..."
age -e -p -o "${TGZ}.age" "${TGZ}"
echo "Removing unencrypted ${TGZ} ..."
rm -v "${TGZ}"
echo "Syncing backups..."
rclone -PL sync bkp/ "${TGT}"