From 1c6f0776e162b63c507a8aa25b78df661dd3c451 Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Wed, 11 May 2022 13:45:34 +0200 Subject: [PATCH] Automate KeepassXC database backup --- .bin/save-passwddb | 11 +++++++++++ .config/systemd/user/save-passwddb.service | 11 +++++++++++ .config/systemd/user/save-passwddb.timer | 10 ++++++++++ 3 files changed, 32 insertions(+) create mode 100755 .bin/save-passwddb create mode 100644 .config/systemd/user/save-passwddb.service create mode 100644 .config/systemd/user/save-passwddb.timer diff --git a/.bin/save-passwddb b/.bin/save-passwddb new file mode 100755 index 0000000..c5b4386 --- /dev/null +++ b/.bin/save-passwddb @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +# Save (encrypted) password database to cloud storage +# +# Can be run manually or daily by enabling the corresponding systemd user +# service and timer, i.e. +# +# `systemctl --user enable save-passwddb.service` +# `systemctl --user enable save-passwddb.timer` + +rclone copy "$HOME/doc/passwd.kdbx" google-drive: diff --git a/.config/systemd/user/save-passwddb.service b/.config/systemd/user/save-passwddb.service new file mode 100644 index 0000000..c65d2a9 --- /dev/null +++ b/.config/systemd/user/save-passwddb.service @@ -0,0 +1,11 @@ +[Unit] +Description=Save KeypassXC password database to cloud +Wants=network-online.target +After=network-online.target + +[Service] +Type=oneshot +ExecStart=/home/h/.bin/save-passwddb + +[Install] +WantedBy=multi-user.target diff --git a/.config/systemd/user/save-passwddb.timer b/.config/systemd/user/save-passwddb.timer new file mode 100644 index 0000000..7a06535 --- /dev/null +++ b/.config/systemd/user/save-passwddb.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Save Keepass password database to cloud daily + +[Timer] +OnCalendar=daily +RandomizedDelaySec=12h +Persistent=true + +[Install] +WantedBy=timers.target