Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ jobs:
run: shellcheck --severity=warning vm/*.sh vm/punchfs/*.sh
- name: shellcheck (live tests)
run: shellcheck --severity=error vm/tests/*.sh
# Ubuntu's /bin/sh is dash: the restart guard and its live test must not lean on bash.
- name: shellcheck (dash)
run: shellcheck -s dash vm/cm-vfs-guard.sh vm/tests/vfs-restart.sh

build-app:
name: Build Swift package
Expand Down
35 changes: 35 additions & 0 deletions mac-app/Sources/CloudMachineCore/BackupHealth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,14 @@ public enum BackupHealth {
/// The share and SMB probes say something only while Samba is meant to run.
public static func probesApply(_ report: VMStatus.Report?) -> Bool { report?.smbdHeld != true }

/// punchfs's `TimeoutStartSec` (vm/systemd/punchfs.service): a cm-vfs-guard run reading
/// longer than this was killed, or hangs.
public static let rebindTimeLimit: TimeInterval = 20 * 60

public static func rebindStillReading(_ age: TimeInterval?) -> Bool {
age.map { $0 <= rebindTimeLimit } ?? false
}

public static func evaluate(
lastSuccess: Date?,
lastAttempt: Date?,
Expand Down Expand Up @@ -219,6 +227,10 @@ public enum BackupHealth {
uploadStalledFor: TimeInterval? = nil,
// The refusal was `storageQuotaExceeded`: the Drive is full (`VMStatus.Report`).
uploadLimitStorageFull: Bool = false,
// Bands an rclone restart left unread (`VMStatus.Report.vfsUnboundBands`); `nil` = none.
vfsUnboundBands: Int? = nil,
// Seconds a cm-vfs-guard run has been reading (`VMStatus.Report.vfsRebindingAge`).
vfsRebindingAge: TimeInterval? = nil,
maxAgeHours: Double = BackupHealth.maxAgeHours,
// Whether the startup grace period is in progress - see `startupGraceMinutes`.
withinStartupGrace: Bool = false,
Expand Down Expand Up @@ -538,6 +550,27 @@ public enum BackupHealth {
}
}

// Samba is off on purpose: a band uploaded before cm-vfs-guard read it may come back as
// zeros (30.11.2026). Not "a service is down" alone: the person learns why.
if let vfsUnboundBands {
let unbound =
Problem(
summary: L10n.tr(
"%@ band(s) not secured after an rclone restart",
vfsUnboundBands > 0 ? "\(vfsUnboundBands)" : "?"),
detail: L10n.tr(
"Time Machine stays off until they are: a band uploaded before it was read after the restart can come back as zeros. The machine reads them again every minute (cm-smb-heal). Check: cloudmachine-agent vm-status, then in the machine: journalctl -u punchfs -u cm-smb-heal | grep cm-vfs-guard"
),
code: "bands-not-secured")
// Every rclone restart runs a rebind (up to 15 min): a note while it reads, a failure
// once it is past punchfs's start timeout or has ended with bands left.
if rebindStillReading(vfsRebindingAge) {
notices.append(unbound)
} else {
problems.append(unbound)
}
}

if let uploadStalledFor {
problems.append(
Problem(
Expand Down Expand Up @@ -811,6 +844,8 @@ public enum BackupHealth {
lastUploadAge: report?.lastUploadAge,
uploadStalledFor: report.flatMap(VMStatus.uploadStalledFor),
uploadLimitStorageFull: report?.uploadLimitStorageFull ?? false,
vfsUnboundBands: report?.vfsUnboundBands,
vfsRebindingAge: report?.vfsRebindingAge,
maxAgeHours: maxAgeHours,
// The REAL clock, not `now`: tests substitute a `now` from the past, and
// uptime computed from it would come out negative, i.e. "startup in
Expand Down
22 changes: 21 additions & 1 deletion mac-app/Sources/CloudMachineCore/DriveEncryption.swift
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,26 @@ public enum DriveEncryption {
}
}

/// Shell words for `rm -rf`: `cachePaths`, plus the `<name>{hash}` folders rclone
/// uses for a remote with config overrides (the mount's --drive-* flags; cmtest
/// 30.11.2026: `gdrive{7LdmB}`). The `{*}` stays outside the quotes: bash does not
/// brace-expand it, the `*` globs; with no match `rm -f` gets the literal path.
static func cacheRemovalWords(remote: String, cacheDir: String = VMLayout.Guest.cacheDir)
-> [String]
{
let parts = remote.split(separator: ":", maxSplits: 1).map(String.init)
let name = parts[0]
let path = parts.count > 1 ? parts[1] : ""
let plain = cachePaths(remote: remote).map {
VMLayout.shellQuoted($0.replacingOccurrences(of: VMLayout.Guest.cacheDir, with: cacheDir))
}
let hashed = ["vfs", "vfsMeta"].map {
VMLayout.shellQuoted("\(cacheDir)/\($0)/\(name)") + "{*}"
+ (path.isEmpty ? "" : VMLayout.shellQuoted("/\(path)"))
}
return plain + hashed
}

/// Points the machine at `newRemote`. Runs after `finalSyncScript`; Samba
/// was stopped before that sync (`move`), so nothing has written since.
///
Expand Down Expand Up @@ -414,7 +434,7 @@ public enum DriveEncryption {
"trap 'echo \"FAILED - the previous folder is back\" >&2; restore' ERR",
"systemctl stop tm-bands-bind punchfs rclone-tm",
"printf '%s\\n' \(VMLayout.shellQuoted(VMLayout.envLine("CM_REMOTE", newRemote))) > \(env)",
"rm -rf " + cachePaths(remote: oldRemote).map(VMLayout.shellQuoted).joined(separator: " "),
"rm -rf " + cacheRemovalWords(remote: oldRemote).joined(separator: " "),
"systemctl start rclone-tm punchfs tm-bands-bind",
"mountpoint -q \"$B\"",
"after=$(find \"$B/\" -type f | wc -l)",
Expand Down
8 changes: 8 additions & 0 deletions mac-app/Sources/CloudMachineCore/L10nPolish+VM.swift
Original file line number Diff line number Diff line change
Expand Up @@ -353,5 +353,13 @@ extension L10nPolish {
"Na udziale maszyny jest otwartych sesji SMB: %@. Restart maszyny teraz przerwałby je w środku pracy Time Machine. Wysuń dysk kopii na Macu albo poczekaj, aż się zamkną (listę pokazuje smbstatus -b w maszynie), i uruchom vm-update ponownie.",
"%@ did not answer - not restarting the machine while it is unknown whether Time Machine is using the share.":
"%@ nie odpowiada - maszyna nie zostanie zrestartowana, dopóki nie wiadomo, czy Time Machine używa udziału.",
"%@ band(s) not secured after an rclone restart":
"Pasma niezabezpieczone po restarcie rclone: %@",
"Time Machine stays off until they are: a band uploaded before it was read after the restart can come back as zeros. The machine reads them again every minute (cm-smb-heal). Check: cloudmachine-agent vm-status, then in the machine: journalctl -u punchfs -u cm-smb-heal | grep cm-vfs-guard":
"Time Machine pozostaje wyłączony, dopóki nie zostaną zabezpieczone: pasmo wysłane, zanim zostało odczytane po restarcie, może wrócić jako zera. Maszyna ponawia odczyt co minutę (cm-smb-heal). Sprawdź: cloudmachine-agent vm-status, potem w maszynie: journalctl -u punchfs -u cm-smb-heal | grep cm-vfs-guard",
"Restart guard: %@ band(s) not secured after an rclone restart - Samba stays off until they are read (cm-smb-heal retries every minute)":
"Ochrona restartu: pasma niezabezpieczone po restarcie rclone: %@ - Samba pozostaje wyłączona, dopóki nie zostaną odczytane (cm-smb-heal ponawia co minutę)",
"Not everything is on Google Drive yet (%@ file(s) waiting to upload, %@ changed file(s) in the cache). Restarting the machine now can bring them back as zeros. Wait until the upload is done (cloudmachine-agent vm-status), then run vm-update again.":
"Nie wszystko jest jeszcze na Dysku Google (pliki czekające na wysłanie: %@, zmienione pliki w buforze: %@). Restart maszyny teraz może przywrócić je jako zera. Poczekaj, aż wysyłka się skończy (cloudmachine-agent vm-status), i uruchom vm-update ponownie.",
]
}
8 changes: 8 additions & 0 deletions mac-app/Sources/CloudMachineCore/L10nTranslations+ar.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,12 @@ extension L10nTranslations {
"عدد جلسات SMB المفتوحة على مشاركة الجهاز: %@. إعادة التشغيل الآن ستقطعها أثناء عمل Time Machine. أخرج قرص النسخ الاحتياطي على الـ Mac أو انتظر حتى تُغلق (يعرضها smbstatus -b داخل الجهاز)، ثم شغّل vm-update مجددًا.",
"%@ did not answer - not restarting the machine while it is unknown whether Time Machine is using the share.":
"%@ لم يستجب - لن يُعاد تشغيل الجهاز ما دام غير معروف هل يستخدم Time Machine المشاركة.",
"%@ band(s) not secured after an rclone restart":
"أشرطة غير مؤمَّنة بعد إعادة تشغيل rclone: %@",
"Time Machine stays off until they are: a band uploaded before it was read after the restart can come back as zeros. The machine reads them again every minute (cm-smb-heal). Check: cloudmachine-agent vm-status, then in the machine: journalctl -u punchfs -u cm-smb-heal | grep cm-vfs-guard":
"يبقى Time Machine متوقفًا حتى يتم تأمينها: الشريط الذي رُفع قبل قراءته بعد إعادة التشغيل قد يعود أصفارًا. تعيد الآلة قراءتها كل دقيقة (cm-smb-heal). تحقق: cloudmachine-agent vm-status، ثم داخل الآلة: journalctl -u punchfs -u cm-smb-heal | grep cm-vfs-guard",
"Restart guard: %@ band(s) not secured after an rclone restart - Samba stays off until they are read (cm-smb-heal retries every minute)":
"حماية إعادة التشغيل: أشرطة غير مؤمَّنة بعد إعادة تشغيل rclone: %@ - يبقى Samba متوقفًا حتى تُقرأ (يعيد cm-smb-heal المحاولة كل دقيقة)",
"First backup in progress: %@":
"النسخة الاحتياطية الأولى قيد التنفيذ: %@",
"First backup in progress: starting":
Expand All @@ -1128,5 +1134,7 @@ extension L10nTranslations {
"لم تكتمل النسخة الاحتياطية الأولى خلال %@",
"Even at Google's limit of 750 GB a day a first backup normally completes within a few days. Check: tmutil status, and cloudmachine-agent vm-status":
"حتى مع حد Google البالغ 750 جيجابايت يوميًا، تكتمل النسخة الاحتياطية الأولى عادةً خلال أيام قليلة. تحقق من: tmutil status و cloudmachine-agent vm-status",
"Not everything is on Google Drive yet (%@ file(s) waiting to upload, %@ changed file(s) in the cache). Restarting the machine now can bring them back as zeros. Wait until the upload is done (cloudmachine-agent vm-status), then run vm-update again.":
"لم يُرفع كل شيء إلى Google Drive بعد (%@ ملف/ملفات بانتظار الرفع، %@ ملف/ملفات متغيرة في ذاكرة التخزين المؤقت). إعادة تشغيل الجهاز الآن قد تعيدها أصفارًا. انتظر حتى ينتهي الرفع (cloudmachine-agent vm-status)، ثم شغّل vm-update مجددًا.",
]
}
8 changes: 8 additions & 0 deletions mac-app/Sources/CloudMachineCore/L10nTranslations+da.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,12 @@ extension L10nTranslations {
"Der er %@ åbne SMB-sessioner på maskinens deling. Hvis maskinen genstartes nu, afbrydes de midt i Time Machines arbejde. Skub backupdisken ud på Mac'en, eller vent til de lukkes (smbstatus -b i maskinen viser dem), og kør derefter vm-update igen.",
"%@ did not answer - not restarting the machine while it is unknown whether Time Machine is using the share.":
"%@ svarede ikke - maskinen genstartes ikke, så længe det er ukendt, om Time Machine bruger delingen.",
"%@ band(s) not secured after an rclone restart":
"%@ bånd ikke sikret efter en genstart af rclone",
"Time Machine stays off until they are: a band uploaded before it was read after the restart can come back as zeros. The machine reads them again every minute (cm-smb-heal). Check: cloudmachine-agent vm-status, then in the machine: journalctl -u punchfs -u cm-smb-heal | grep cm-vfs-guard":
"Time Machine forbliver slået fra, indtil de er sikret: et bånd, der blev uploadet før det blev læst efter genstarten, kan komme tilbage som nuller. Maskinen læser dem igen hvert minut (cm-smb-heal). Tjek: cloudmachine-agent vm-status, derefter i maskinen: journalctl -u punchfs -u cm-smb-heal | grep cm-vfs-guard",
"Restart guard: %@ band(s) not secured after an rclone restart - Samba stays off until they are read (cm-smb-heal retries every minute)":
"Genstartsvagt: %@ bånd ikke sikret efter en genstart af rclone - Samba forbliver slået fra, indtil de er læst (cm-smb-heal prøver igen hvert minut)",
"First backup in progress: %@":
"Første backup i gang: %@",
"First backup in progress: starting":
Expand All @@ -1128,5 +1134,7 @@ extension L10nTranslations {
"Den første backup er ikke afsluttet på %@",
"Even at Google's limit of 750 GB a day a first backup normally completes within a few days. Check: tmutil status, and cloudmachine-agent vm-status":
"Selv med Googles grænse på 750 GB i døgnet bliver en første backup normalt færdig på få dage. Kontrollér: tmutil status og cloudmachine-agent vm-status",
"Not everything is on Google Drive yet (%@ file(s) waiting to upload, %@ changed file(s) in the cache). Restarting the machine now can bring them back as zeros. Wait until the upload is done (cloudmachine-agent vm-status), then run vm-update again.":
"Ikke alt er på Google Drev endnu (%@ fil(er) venter på upload, %@ ændret/ændrede fil(er) i cachen). En genstart af maskinen nu kan give dem tilbage som nuller. Vent, til uploaden er færdig (cloudmachine-agent vm-status), og kør derefter vm-update igen.",
]
}
8 changes: 8 additions & 0 deletions mac-app/Sources/CloudMachineCore/L10nTranslations+de.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,12 @@ extension L10nTranslations {
"Auf der Freigabe der Maschine sind %@ SMB-Sitzungen offen. Ein Neustart würde sie mitten in der Arbeit von Time Machine unterbrechen. Werfen Sie das Backup-Volume am Mac aus oder warten Sie, bis sie geschlossen sind (smbstatus -b in der Maschine zeigt sie), und führen Sie dann vm-update erneut aus.",
"%@ did not answer - not restarting the machine while it is unknown whether Time Machine is using the share.":
"%@ hat nicht geantwortet – die Maschine wird nicht neu gestartet, solange unbekannt ist, ob Time Machine die Freigabe nutzt.",
"%@ band(s) not secured after an rclone restart":
"%@ Band(s) nach einem rclone-Neustart nicht gesichert",
"Time Machine stays off until they are: a band uploaded before it was read after the restart can come back as zeros. The machine reads them again every minute (cm-smb-heal). Check: cloudmachine-agent vm-status, then in the machine: journalctl -u punchfs -u cm-smb-heal | grep cm-vfs-guard":
"Time Machine bleibt aus, bis sie gesichert sind: Ein Band, das vor dem Lesen nach dem Neustart hochgeladen wurde, kann als Nullen zurückkommen. Die Maschine liest sie jede Minute erneut (cm-smb-heal). Prüfen: cloudmachine-agent vm-status, dann in der Maschine: journalctl -u punchfs -u cm-smb-heal | grep cm-vfs-guard",
"Restart guard: %@ band(s) not secured after an rclone restart - Samba stays off until they are read (cm-smb-heal retries every minute)":
"Neustartschutz: %@ Band(s) nach einem rclone-Neustart nicht gesichert – Samba bleibt aus, bis sie gelesen sind (cm-smb-heal versucht es jede Minute erneut)",
"First backup in progress: %@":
"Erstes Backup läuft: %@",
"First backup in progress: starting":
Expand All @@ -1128,5 +1134,7 @@ extension L10nTranslations {
"Das erste Backup ist in %@ nicht abgeschlossen worden",
"Even at Google's limit of 750 GB a day a first backup normally completes within a few days. Check: tmutil status, and cloudmachine-agent vm-status":
"Selbst beim Google-Limit von 750 GB pro Tag ist ein erstes Backup normalerweise nach wenigen Tagen fertig. Prüfen: tmutil status und cloudmachine-agent vm-status",
"Not everything is on Google Drive yet (%@ file(s) waiting to upload, %@ changed file(s) in the cache). Restarting the machine now can bring them back as zeros. Wait until the upload is done (cloudmachine-agent vm-status), then run vm-update again.":
"Noch ist nicht alles in Google Drive (%@ Datei(en) warten auf den Upload, %@ geänderte Datei(en) im Cache). Ein Neustart der Maschine jetzt kann sie als Nullen zurückbringen. Warten Sie, bis der Upload fertig ist (cloudmachine-agent vm-status), und führen Sie dann vm-update erneut aus.",
]
}
8 changes: 8 additions & 0 deletions mac-app/Sources/CloudMachineCore/L10nTranslations+es.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1106,6 +1106,12 @@ extension L10nTranslations {
"Hay %@ sesiones SMB abiertas en el recurso compartido de la máquina. Reiniciarla ahora las cortaría en pleno trabajo de Time Machine. Expulsa el disco de copia en el Mac o espera a que se cierren (smbstatus -b en la máquina las muestra) y vuelve a ejecutar vm-update.",
"%@ did not answer - not restarting the machine while it is unknown whether Time Machine is using the share.":
"%@ no respondió: la máquina no se reiniciará mientras no se sepa si Time Machine usa el recurso compartido.",
"%@ band(s) not secured after an rclone restart":
"%@ banda(s) sin asegurar tras un reinicio de rclone",
"Time Machine stays off until they are: a band uploaded before it was read after the restart can come back as zeros. The machine reads them again every minute (cm-smb-heal). Check: cloudmachine-agent vm-status, then in the machine: journalctl -u punchfs -u cm-smb-heal | grep cm-vfs-guard":
"Time Machine sigue detenido hasta que lo estén: una banda subida antes de leerse tras el reinicio puede volver como ceros. La máquina las vuelve a leer cada minuto (cm-smb-heal). Comprueba: cloudmachine-agent vm-status y, en la máquina: journalctl -u punchfs -u cm-smb-heal | grep cm-vfs-guard",
"Restart guard: %@ band(s) not secured after an rclone restart - Samba stays off until they are read (cm-smb-heal retries every minute)":
"Guarda reinicio: %@ banda(s) sin asegurar tras un reinicio de rclone; Samba sigue detenido hasta leerlas (cm-smb-heal reintenta cada minuto)",
"First backup in progress: %@":
"Primera copia en curso: %@",
"First backup in progress: starting":
Expand All @@ -1128,5 +1134,7 @@ extension L10nTranslations {
"La primera copia no ha terminado en %@",
"Even at Google's limit of 750 GB a day a first backup normally completes within a few days. Check: tmutil status, and cloudmachine-agent vm-status":
"Incluso con el límite de Google de 750 GB al día, una primera copia suele terminar en pocos días. Comprobar: tmutil status y cloudmachine-agent vm-status",
"Not everything is on Google Drive yet (%@ file(s) waiting to upload, %@ changed file(s) in the cache). Restarting the machine now can bring them back as zeros. Wait until the upload is done (cloudmachine-agent vm-status), then run vm-update again.":
"Todavía no está todo en Google Drive (%@ archivo(s) esperando la subida, %@ archivo(s) modificado(s) en la caché). Reiniciar la máquina ahora puede devolverlos como ceros. Espera a que termine la subida (cloudmachine-agent vm-status) y vuelve a ejecutar vm-update.",
]
}
Loading
Loading