Maintenance commands: doctor, records check, restore, sign out all, more

- sam:doctor: health report (secret key, address, HTTPS, SMTP and SSO
  reachable, Google Drive, migrations, disk, jobs, backup/check/off-site/
  procedures/audit recency); exits 1 on a failure
- records:check: backup now + history and signature check; exits 1 on a problem
- backups:list / backups:restore[file]: checks the copy (nightly or Drive
  .gz), refuses while the server runs, moves the current DB aside, asks
  (CONFIRM=yes to skip)
- users:sign_out_all, sam:records_package[tail], email:test[address],
  offsite:backup, offsite:restore_test
- Admin guide: maintenance commands table, restore steps use backups:restore

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
rickyandClaude Opus 5.5 committed 2026-11-07 16:42:52 -05:00
1 parent 20fe485f10
commit 1412470cd5
11 files changed
+434 -11

No files matched your search

+4 -4
View File
@@ -7,14 +7,14 @@ class OffsiteBackupJob < ApplicationJob
def perform(kind = "backup")
return unless OffsiteConnection.connected?
run = kind == "restore_test" ? OffsiteBackup.restore_test! : backup
run = kind == "restore_test" ? OffsiteBackup.restore_test! : self.class.backup
return if run.nil? || run.ok || !MailSettings.configured?
User.active.where(admin: true).find_each { AdminMailer.offsite_alert(_1, run).deliver_now }
end
private
def backup
# Copies the latest verified backup (making one if there's none from the
# last day). Returns the OffsiteRun. Also used by bin/rails offsite:backup.
def self.backup
latest = BackupRun.where(ok: true).order(:created_at, :id).last
latest = DatabaseBackup.run! unless latest && latest.created_at > 1.day.ago && latest.path.present? && File.exist?(latest.path)
return OffsiteRun.create!(kind: "backup", ok: false, message: "No verified database backup to copy: #{latest.message}") unless latest.ok