From 674b413b4be6847f35bbd6b6ba432af5924ebfbb Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sun, 12 Jul 2026 15:11:29 -0700 Subject: [PATCH] Make message backups coverage-driven --- nixos/flake.lock | 12 ++++++------ nixos/git-sync.nix | 21 ++++++++++++++++----- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/nixos/flake.lock b/nixos/flake.lock index df347d1a..ef4bef0c 100644 --- a/nixos/flake.lock +++ b/nixos/flake.lock @@ -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": { diff --git a/nixos/git-sync.nix b/nixos/git-sync.nix index 6a830205..2a8a73ec 100644 --- a/nixos/git-sync.nix +++ b/nixos/git-sync.nix @@ -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"; };