feat: add scheduled backups with borg
This commit is contained in:
parent
7c897dbfc2
commit
edb34572a0
4 changed files with 73 additions and 0 deletions
57
bin/.local/bin/backup.sh
Executable file
57
bin/.local/bin/backup.sh
Executable 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
|
6
systemd/.config/systemd/user/backups.service
Normal file
6
systemd/.config/systemd/user/backups.service
Normal file
|
@ -0,0 +1,6 @@
|
|||
[Unit]
|
||||
Description=Backup this computer to a remote server
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=%h/.local/bin/backups.sh
|
9
systemd/.config/systemd/user/backups.timer
Normal file
9
systemd/.config/systemd/user/backups.timer
Normal file
|
@ -0,0 +1,9 @@
|
|||
[Unit]
|
||||
Description=Backup this computer to a remote server
|
||||
|
||||
[Timer]
|
||||
OnUnitActiveSec=15m
|
||||
Unit=backups.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
1
systemd/.config/systemd/user/timers.target.wants/backups.timer
Symbolic link
1
systemd/.config/systemd/user/timers.target.wants/backups.timer
Symbolic link
|
@ -0,0 +1 @@
|
|||
/home/bca/.config/systemd/user/backups.timer
|
Loading…
Add table
Reference in a new issue