backup: the panel's full backup works, without the queue
Found by the e2e restore scenario of the next commit: the Full backup button answered 200 with ten bytes. The archive includes the Postfix queue, Postfix keeps every queue file and directory readable by its own user alone (not configurable), and the panel runs as its own user - the walk stopped at /data/postfix/queue/active with "permission denied" after the headers were out. So since the queue moved under /data in 1.3.0. Confirmed on the test server: selfpost-backup as root makes the whole archive, the same command as user panel fails the same way. Owner, 2026-10-11: the panel's archive comes without the queue. - backup.Params.Unprivileged: the queue is left out, and so is a file under certs/ that cannot be opened (the private key on the test server is root and Postfix's group only), named through OnWarn. The selfpost-backup command leaves it unset and takes both, as before. - backup.Check reads through everything Create would archive, writing nothing. The panel runs it before the first byte: a failure is a message on the page, not a download cut short. - The box, Help (design commit before this one) and the guide say what the panel's archive leaves out; the guide's comparison table has rows for the queue and the private key, and tells to put the key back before starting a restored instance. go vet ./internal/backup/ ./internal/web/handlers/: ok go test ./internal/backup/ ./cmd/... ./internal/web/...: ok make e2e on the test server, with the restore scenario: ok Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -235,3 +235,47 @@ func TestCheckRestoreWrongFormatRejected(t *testing.T) {
|
||||
t.Error("CheckRestore wrong format reported a restore")
|
||||
}
|
||||
}
|
||||
|
||||
// The panel's archive: no Postfix queue, everything else as before, and Check
|
||||
// agrees that it can be made.
|
||||
func TestCreateUnprivilegedLeavesTheQueueOut(t *testing.T) {
|
||||
dataDir, dbPath, deployRoot := seedDataDir(t)
|
||||
p := Params{DataDir: dataDir, DBPath: dbPath, Version: "1.2.3", DeployRoot: deployRoot, Unprivileged: true}
|
||||
|
||||
if err := Check(p); err != nil {
|
||||
t.Fatalf("Check: %v", err)
|
||||
}
|
||||
var buf bytes.Buffer
|
||||
if err := Create(&buf, p); err != nil {
|
||||
t.Fatalf("Create: %v", err)
|
||||
}
|
||||
files := readArchive(t, buf.Bytes())
|
||||
for name := range files {
|
||||
if strings.HasPrefix(name, DataArchivePrefix+QueueDir) {
|
||||
t.Errorf("the panel's archive holds %s", name)
|
||||
}
|
||||
}
|
||||
for _, name := range []string{
|
||||
DataArchivePrefix + "selfpost.db",
|
||||
DataArchivePrefix + "opendkim/keys/example.com/selfpost.private",
|
||||
DataArchivePrefix + "sasl/sasldb2",
|
||||
DataArchivePrefix + "postfix/sender_login_maps",
|
||||
ComposeFileName, EnvFileName,
|
||||
CertsDirName + "/fullchain.pem",
|
||||
} {
|
||||
if _, ok := files[name]; !ok {
|
||||
t.Errorf("archive missing %s", name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check finds what Create would stumble over, before anything is written.
|
||||
func TestCheckReportsWhatCannotBeRead(t *testing.T) {
|
||||
dataDir, dbPath, deployRoot := seedDataDir(t)
|
||||
if err := os.Remove(filepath.Join(deployRoot, EnvFileName)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if err := Check(Params{DataDir: dataDir, DBPath: dbPath, Version: "1.2.3", DeployRoot: deployRoot}); err == nil {
|
||||
t.Fatal("Check passed with .env missing from the deploy root")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user