Make message backups coverage-driven

This commit is contained in:
2026-07-12 15:11:29 -07:00
parent ef81c601b0
commit 674b413b4b
2 changed files with 22 additions and 11 deletions

12
nixos/flake.lock generated
View File

@@ -720,11 +720,11 @@
]
},
"locked": {
"lastModified": 1783888080,
"narHash": "sha256-1vLrhj0rLtzAdl4ZhZQvPbkfDTecpiajIi+aELuJy7k=",
"lastModified": 1783892979,
"narHash": "sha256-6uwkCVzjTxBweTCZ4CNfwYWNZlL7ri7fe8igy0Fd/ec=",
"owner": "colonelpanic8",
"repo": "gmcli",
"rev": "b85f1671eb5eeaedafdbd88c418451ed1ecbd0b3",
"rev": "f4f3424091377bddf2359b3f5510a65fcc150e29",
"type": "github"
},
"original": {
@@ -1417,11 +1417,11 @@
]
},
"locked": {
"lastModified": 1783748403,
"narHash": "sha256-q+GrnWK5GO4vaTsOrCMQR2Cze7nrgUnGyF8V6x3hGr0=",
"lastModified": 1783886947,
"narHash": "sha256-qItwicCUOoUJy/mrGvIgsMe31H3qlkL0n8I1F3s8qR4=",
"owner": "colonelpanic8",
"repo": "keepbook",
"rev": "d2d666e967048b2478476aeb9e3f6f8b0c034a36",
"rev": "093a3bd76a524b8f3096c5fcdcd6c7ee41c53acb",
"type": "github"
},
"original": {

View File

@@ -14,12 +14,21 @@
gmcliPackage = inputs.gmcli.packages.${pkgs.stdenv.hostPlatform.system}.default;
gmcliArchiveRoot = "/home/imalison/Backups/gmcli/git-sync";
gmcliArchiveOutput = "${gmcliArchiveRoot}/archive";
gmcliTelephonyOutput = "${gmcliArchiveRoot}/telephony";
gmcliBackupLock = "/home/imalison/.local/state/gmcli/backup.lock";
exportGmcliArchive = pkgs.writeShellScript "export-gmcli-archive" ''
set -euo pipefail
${gmcliPackage}/bin/gmcli export jsonl --out ${lib.escapeShellArg gmcliArchiveOutput} --force
${gmcliPackage}/bin/gmcli export verify --dir ${lib.escapeShellArg gmcliArchiveOutput}
'';
exportGmcliTelephonyArchive = pkgs.writeShellScript "export-gmcli-telephony-archive" ''
set -euo pipefail
${gmcliPackage}/bin/gmcli android export-telephony \
--adb ${pkgs.android-tools}/bin/adb \
--out ${lib.escapeShellArg gmcliTelephonyOutput} \
--force --include-part-data=false
${gmcliPackage}/bin/gmcli android verify-telephony --dir ${lib.escapeShellArg gmcliTelephonyOutput}
'';
refreshGmcliArchiveUnlocked = pkgs.writeShellScript "refresh-gmcli-archive-unlocked" ''
set -uo pipefail
status=0
@@ -65,15 +74,17 @@
status=1
fi
${exportGmcliArchive} || status=1
${exportGmcliTelephonyArchive} || status=1
${gmcliPackage}/bin/gmcli coverage verify || status=1
exit "$status"
'';
withGmcliBackupLock = name: command:
pkgs.writeShellScript name ''
set -euo pipefail
exec 9>${lib.escapeShellArg gmcliBackupLock}
if ! ${pkgs.util-linux}/bin/flock --nonblock 9; then
echo "Another gmcli backup job is already running; skipping."
exit 0
if ! ${pkgs.util-linux}/bin/flock --wait 1200 9; then
echo "Timed out waiting 20 minutes for another gmcli backup job" >&2
exit 1
fi
exec ${command}
'';
@@ -185,9 +196,9 @@ in {
};
systemd.user.timers.gmcli-archive-backfill = {
Unit.Description = "Weekly deep Google Messages history backfill";
Unit.Description = "Daily deep Google Messages history backfill";
Timer = {
OnCalendar = "Sun *-*-* 04:00:00";
OnCalendar = "*-*-* 04:00:00";
Persistent = true;
RandomizedDelaySec = "2h";
};