Files
dotfiles/.local/bin/library-dump
T
Daniele Fucini cd439be109 Add a daily dump of the Library database
library-dump.timer writes Library-<weekday>.sql.gz to
~/.local/share/library_manager/dumps, which simple_backup then copies;
the login comes from ~/.config/library_manager/dump.cnf (not tracked).
2026-10-25 19:05:24 +01:00

18 lines
557 B
Bash
Executable File

#!/bin/bash
# Dump the Library database to a per-weekday file (seven self-rotating copies).
set -euo pipefail
cnf=${XDG_CONFIG_HOME:-$HOME/.config}/library_manager/dump.cnf
dir=${XDG_DATA_HOME:-$HOME/.local/share}/library_manager/dumps
out=$dir/Library-$(LC_ALL=C date +%a).sql.gz
umask 077
mkdir -p "$dir"
# Write to a temporary file so a failed dump never replaces a good one
tmp=$(mktemp "$dir/.dump.XXXXXX")
trap 'rm -f "$tmp"' EXIT
mariadb-dump --defaults-extra-file="$cnf" --single-transaction --databases Library | gzip > "$tmp"
mv "$tmp" "$out"