feat: add scheduled backups with borg

This commit is contained in:
Bruno Carlin 2022-08-12 23:59:24 +02:00
parent 7c897dbfc2
commit edb34572a0
4 changed files with 73 additions and 0 deletions

57
bin/.local/bin/backup.sh Executable file
View file

@ -0,0 +1,57 @@
#!/usr/bin/env bash
rsync-cmd() {
if [[ -n "$1" ]]; then
dry_run="--dry-run"
fi
rsync --verbose \
--recursive \
--links \
--perms \
--times \
-D \
--update \
--delete-after \
--compress \
--human-readable \
--progress \
--partial \
$dry_run \
"$HOME/Progs" "$HOME/Téléchargements" tria.waarp.org:~/backup
}
#case $1 in
# "test")
# rsync-cmd true
# ;;
# *)
# rsync-cmd
# ;;
#esac
export BORG_REPO="tria.waarp.org:~/borg-backups"
export BORG_PASSCOMMAND='secret-tool lookup borg passphrase'
borg create \
--verbose \
--filter AME \
--list \
--stats \
--show-rc \
--compression zstd,11 \
"::$(date --iso-8601=minute)" \
"$HOME/Progs" \
"$HOME/Téléchargements"
borg prune \
--list \
--show-rc \
--keep-hourly 24 \
--keep-daily 7 \
--keep-weekly 4 \
--keep-monthly 6 \
--keep-yearly 1
borg compact
borg info

View file

@ -0,0 +1,6 @@
[Unit]
Description=Backup this computer to a remote server
[Service]
Type=oneshot
ExecStart=%h/.local/bin/backups.sh

View file

@ -0,0 +1,9 @@
[Unit]
Description=Backup this computer to a remote server
[Timer]
OnUnitActiveSec=15m
Unit=backups.service
[Install]
WantedBy=timers.target

View file

@ -0,0 +1 @@
/home/bca/.config/systemd/user/backups.timer