From 84f2e3c33538587129c8b3d9898ef1625ccd557b Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Fri, 8 Sep 2023 23:23:56 +0200 Subject: Back up Syncthing data separately This should allow sharing the underlying data with backups from fp4.twilken.net. --- tw/home/files/zshrc | 17 ++++++++++++++--- tw/home/lap.scm | 21 +++++++++++++-------- 2 files changed, 27 insertions(+), 11 deletions(-) (limited to 'tw/home') diff --git a/tw/home/files/zshrc b/tw/home/files/zshrc index 1e8afcaa..56964477 100644 --- a/tw/home/files/zshrc +++ b/tw/home/files/zshrc @@ -101,9 +101,6 @@ alias ipy='ipython3 --autoindent --automagic --pprint --no-banner --no-confirm-e alias rot13='caesar 13' alias pdsh='\pdsh -SR ssh -f 64' alias wget='\wget --hsts-file="${XDG_CACHE_HOME:-$HOME/.cache}/wget-hsts"' -# Set RESTIC_REPOSITORY here, since we have to run pass(1) to generate it. -# RESTIC_PASSWORD_COMMAND is set separately, since it's a static string that restic will execute. -alias restic='RESTIC_REPOSITORY="rest:http://timo:$(pass computers/vin/restic-server/timo | head -1)@vin.wg:8181/timo/laptop" \restic' alias aurora="REQUESTS_CA_BUNDLE=${XDG_CONFIG_HOME:-$HOME/.config}/cern-ca-bundle.crt \aurora" alias aurora_admin="REQUESTS_CA_BUNDLE=${XDG_CONFIG_HOME:-$HOME/.config}/cern-ca-bundle.crt \aurora_admin" alias nomad='NOMAD_TOKEN=$(pass cern/ci/nomad-bootstrap-token | head -1) \nomad' @@ -115,6 +112,20 @@ alias vault='VAULT_TOKEN=$(pass cern/ci/vault-root-token | head -1) \vault' nomad-shell () { nomad alloc exec "$1" sh -c 'export TERM=xterm-256color HOME=$NOMAD_TASK_DIR PS1="\\u@\\h \\w \\\$ "; cd; exec bash -i' } +restic () { + if [ $# -eq 0 ]; then + command restic + echo >&2; echo 'Pass the repo name as the first parameter.' >&2 + else + local repo=$1; shift + echo "running: R_REPO=rest:.../$USERNAME/$repo restic $*" >&2 + # Set RESTIC_REPOSITORY here, since we have to run pass(1) to generate it. + # RESTIC_PASSWORD_COMMAND is set separately, since it's a static string that restic will execute. + RESTIC_PASSWORD_COMMAND="pass computers/vin/restic-repos/$repo" \ + RESTIC_REPOSITORY="rest:http://timo:$(pass "computers/vin/restic-server/$USERNAME" | head -1)@vin.wg:8181/$USERNAME/$repo" \ + command restic "$@" + fi +} # Git aliases alias ga='git add' diff --git a/tw/home/lap.scm b/tw/home/lap.scm index e5149e5d..e0f23c70 100644 --- a/tw/home/lap.scm +++ b/tw/home/lap.scm @@ -116,18 +116,11 @@ (home-batsignal-configuration (batteries '("BAT0")))) - (simple-service 'restic-environment home-environment-variables-service-type - ;; This variable is useful in interactive shells. - ;; See also the restic alias in zshrc. - `(("RESTIC_PASSWORD_COMMAND" . "pass computers/vin/restic-repos/laptop"))) - (service home-restic-backup-service-type (list (restic-backup-repository (schedule #~"0 */2 * * *") (paths '(;; important user data - "~/audiobooks" "~/documents" - "~/pictures" "~/src" "~/.local/share/zsh/history" ;; secrets @@ -136,6 +129,7 @@ "~/.config/cern-ca-bundle.crt" "~/.config/grid-personal-cert.pem" "~/.config/grid-personal-key.pem" + "~/.config/syncthing" ;; games "~/savegames" "~/.config/simutrans" @@ -145,7 +139,18 @@ "~/.local/share/guix-sandbox-home/.local/share/Colossal Order/Cities_Skylines" "~/.local/share/guix-sandbox-home/.local/share/Surviving Mars")) (url-command "echo \"rest:http://timo:$(pass computers/vin/restic-server/timo | head -1)@vin.wg:8181/timo/laptop\"") - (password-command "pass computers/vin/restic-repos/laptop")))) + (password-command "pass computers/vin/restic-repos/laptop")) + + (restic-backup-repository + (schedule #~"10 */2 * * *") + (paths '("~/audiobooks" + "~/music" + "~/pictures" + "~/sync" + "~/videos/youtube/.yt-dlp" + "~/videos/youtube/.config")) + (url-command "echo \"rest:http://timo:$(pass computers/vin/restic-server/timo | head -1)@vin.wg:8181/timo/sync\"") + (password-command "pass computers/vin/restic-repos/sync")))) ;; Redshift: make the screen turn redder at night. (service home-redshift-service-type -- cgit v1.2.3