Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
0ad31c9
fix(storage): mask RCLONE_FLAGS values in the run log
tis24dev Nov 2, 2026
d72453a
fix(telegram): keep the bot server's answer out of the startup WARNING
tis24dev Nov 2, 2026
97b4adf
fix(storage): mask RCLONE_FLAGS values in every form they reach the log
tis24dev Nov 2, 2026
2dc0ce2
test(telegram): write the bidi rune of the startup test as an escape
tis24dev Nov 2, 2026
20241ef
fix(webhook): name the status, not the endpoint's answer, in failure …
tis24dev Nov 2, 2026
ed68c42
fix(upgrade): name GitHub's status, not its answer, in the upgrade error
tis24dev Nov 2, 2026
6ec4b39
fix(webhook): mask the URL's path, query and header values in the ans…
tis24dev Nov 2, 2026
b464991
fix(notify): keep the server's answer out of Telegram and Gotify errors
tis24dev Nov 2, 2026
e03cf93
fix(webhook): mask userinfo, escaped forms and header words in the an…
tis24dev Nov 2, 2026
55c8a1a
fix(webhook): mask the userinfo basic-auth form and bare query pairs …
tis24dev Nov 2, 2026
93c2967
fix(orchestrator): count the run log past a line longer than 1 MiB
tis24dev Nov 2, 2026
9dce359
fix(config): read "$$" in backup.env as a literal "$"
tis24dev Nov 2, 2026
26f9010
style(upgrade): use errors.AsType for the GitHub status error
tis24dev Nov 2, 2026
acc66ae
fix(storage): find a path's mount by device, so a symlinked destinati…
tis24dev Nov 3, 2026
62d5b52
fix(cli): refuse --dry-run with the modes that ignored it; --upgrade-…
tis24dev Nov 3, 2026
c96df24
fix(install): read the crontab back before removing the daemon on a s…
tis24dev Nov 3, 2026
6439cd8
fix(storage): set the mode of local cloud copies on a filesystem with…
tis24dev Nov 3, 2026
5cca77f
fix(storage): fail closed and refuse symlinks when setting local clou…
tis24dev Nov 3, 2026
c8025d5
fix(permissions): leave a disabled secondary alone in SET_BACKUP_PERM…
tis24dev Nov 3, 2026
9d5abcb
fix(security): neither create nor check the paths of a disabled secon…
tis24dev Nov 3, 2026
0afdc5e
fix(install): the permissions footer names the backup paths it skipped
tis24dev Nov 3, 2026
6127f5c
fix(support): a failed support email gets its own WARNING
tis24dev Nov 3, 2026
e165ccc
fix(email): count queued messages, not lines with an address
tis24dev Nov 3, 2026
64b7379
fix(email): read PBS user.cfg as section-config in the recipient fall…
tis24dev Nov 3, 2026
6c300a4
fix(cli): stop offering the removed proxmox-backup alias
tis24dev Nov 3, 2026
94bfd31
fix(upgrade): exit 130 on an interruption, 0 on an unanswered prompt,…
tis24dev Nov 3, 2026
ba3fd4f
fix(install): an incomplete post-install dry-run is no longer "no unu…
tis24dev Nov 3, 2026
3423786
fix(install): Ctrl+C on the TUI Healthchecks step aborts the install
tis24dev Nov 3, 2026
73537fd
fix(daemon): follow a symlinked backup.env in the daemon-mode writes
tis24dev Nov 3, 2026
0223d48
fix(cron): see an /etc cron line with an assignment in front of the c…
tis24dev Nov 3, 2026
9a6473b
fix(logging): mark lost run-log lines and count them in the exit code
tis24dev Nov 4, 2026
61425db
fix(config): default CLOUD_LOG_PATH to a relative path, like the backups
tis24dev Nov 4, 2026
d16e280
style(config): range over strings.SplitSeq in the template test
tis24dev Nov 4, 2026
c554c45
fix(decrypt): honour --log-level like backup and restore
tis24dev Nov 4, 2026
66efca8
fix(config): stop reading the Bash-era DISABLE_COLORS
tis24dev Nov 4, 2026
c5b363f
docs(daemon): say a personal script sees its name as /proc/self/fd/3
tis24dev Nov 4, 2026
9b777e0
fix(storage): classify CephFS as a network filesystem the ownership p…
tis24dev Nov 4, 2026
0f32add
fix(backup): skip dedup when the run's exclusions would drop its mani…
tis24dev Nov 4, 2026
c95ac3f
chore(whatsnew): add the 0.46.1 entry
tis24dev Nov 4, 2026
30826e8
feat(healthchecks): send an initial email for the monitoring portal
tis24dev Nov 13, 2026
f2732af
test(healthchecks): pin that the setup check keeps the relay's login_…
tis24dev Nov 13, 2026
8464d06
fix(healthchecks): send the initial email at daemon start too
tis24dev Nov 13, 2026
dd26778
fix(healthchecks): line-per-fact texts for the portal sign-in line an…
tis24dev Nov 13, 2026
f8faf9e
feat(install): ask the HC initial account email with the ProxSave HC …
tis24dev Nov 13, 2026
d7ab01e
chore(whatsnew): fold the unreleased 0.46.1 entry into 0.47.0
tis24dev Nov 13, 2026
2725242
fix(install): satisfy staticcheck and modernize on the initial email …
tis24dev Nov 13, 2026
315251f
fix(build): require Go 1.26.11 for GO-2026-6859 in net/http
tis24dev Nov 13, 2026
d6eaad3
fix(email): read the PVE and PBS user.cfg through safefs
tis24dev Nov 13, 2026
d4de954
test(scripts): count only the personal-script probe's parked opens
tis24dev Nov 13, 2026
11e6b41
fix(daemon): keep the initial email due until its answer is logged
tis24dev Nov 13, 2026
eef6d28
fix(install): verify the cron line just written before removing the d…
tis24dev Nov 13, 2026
5cef80f
fix(permissions): report walk entries whose chown or chmod failed
tis24dev Nov 13, 2026
513da80
fix(installer): refuse "$" in the portal initial email
tis24dev Nov 13, 2026
0f156b5
fix(notify): do not count sendmail's mailq footer as a queued message
tis24dev Nov 13, 2026
3ec1653
fix(storage): confine the local cloud chmods to the CLOUD_REMOTE dire…
tis24dev Nov 13, 2026
f503193
fix(storage): report a mode not set on cloud and secondary copies wit…
tis24dev Nov 13, 2026
5f0eaa3
fix(storage): leave the mode alone on FAT-family cloud and secondary …
tis24dev Nov 13, 2026
8388932
test(orchestrator): pin that the cloud log chmod only sees paths insi…
tis24dev Nov 13, 2026
51277f4
fix(notify): read the log attached to the mail through safefs
tis24dev Nov 13, 2026
de432b8
fix(storage): recognise an msdos mount as a FAT-family filesystem
tis24dev Nov 13, 2026
faf3ce6
fix(storage): give an msdos mount its own filesystem type
tis24dev Nov 13, 2026
bd3dbfb
docs: name the Go 1.26.11 floor that go.mod and the runtime check enf…
tis24dev Nov 13, 2026
dfb1502
fix(upgrade): repoint the legacy cron command field, not the first match
tis24dev Nov 13, 2026
ea92e13
fix(permissions): count failed walk entries at the backup path loop
tis24dev Nov 13, 2026
b7646f2
fix(permissions): walk the directory behind a symlinked backup path
tis24dev Nov 13, 2026
b84aaa6
fix(permissions): count a subdirectory the permission walk could not …
tis24dev Nov 13, 2026
03ebda9
fix(daemon): keep the daemon when the revert's cron entry is not read…
tis24dev Nov 13, 2026
fd7922d
fix(dashboard): drop the teardown screen's unreachable no-cron-entry arm
tis24dev Nov 13, 2026
a4b8fb8
fix(daemon): show a late initial email answer after the backup finished
tis24dev Nov 13, 2026
451c15b
test(daemon): release held relay answers once, before the server closes
tis24dev Nov 13, 2026
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
75 changes: 75 additions & 0 deletions cmd/proxsave/backup_env_symlink_write_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package main

import (
"bytes"
"os"
"path/filepath"
"strings"
"testing"

"github.com/tis24dev/proxsave/internal/logging"
"github.com/tis24dev/proxsave/internal/types"
)

// A configs/backup.env that is an absolute or escaping symlink was refused by the
// daemon-mode writes ("path escapes from parent") while the loader followed it: the
// switch to the daemon removed the cron line and recorded nothing. The write now
// follows the link to its target, and the link stays a link.
func TestSetBackupEnvKeysFollowsASymlinkedConfig(t *testing.T) {
for _, tc := range []struct {
name string
link func(target, configs string) string
}{
{"absolute link outside", func(target, _ string) string { return target }},
{"relative link escaping", func(target, configs string) string {
rel, _ := filepath.Rel(configs, target)
return rel
}},
} {
t.Run(tc.name, func(t *testing.T) {
root := t.TempDir()
target := filepath.Join(root, "etc", "proxsave", "backup.env")
configs := filepath.Join(root, "base", "configs")
for _, d := range []string{filepath.Dir(target), configs} {
if err := os.MkdirAll(d, 0o755); err != nil {
t.Fatal(err)
}
}
if err := os.WriteFile(target, []byte("SCHEDULER_MODE=cron\n"), 0o600); err != nil {
t.Fatal(err)
}
link := filepath.Join(configs, "backup.env")
if err := os.Symlink(tc.link(target, configs), link); err != nil {
t.Fatal(err)
}
if err := setBackupEnvKeys(link, map[string]string{"SCHEDULER_MODE": "daemon"}); err != nil {
t.Fatalf("setBackupEnvKeys: %v", err)
}
data, err := os.ReadFile(target)
if err != nil || !strings.Contains(string(data), "SCHEDULER_MODE=daemon") {
t.Fatalf("target = %q (%v), want SCHEDULER_MODE=daemon", data, err)
}
if fi, err := os.Lstat(link); err != nil || fi.Mode()&os.ModeSymlink == 0 {
t.Fatalf("the link was replaced: %v %v", fi.Mode(), err)
}
})
}
}

// The adoption that cannot read backup.env logged only DEBUG while the cron line was
// removed anyway; it is now the WARNING a failed write already gets.
func TestScheduleAdoptionWarnsWhenBackupEnvCannotBeRead(t *testing.T) {
var out bytes.Buffer
bootstrap := logging.NewBootstrapLogger()
bootstrap.SetConsoleQuiet(true)
mirror := logging.New(types.LogLevelDebug, false)
mirror.SetOutput(&out)
bootstrap.SetMirrorLogger(mirror)
adoptSchedulerTimeForDaemon(filepath.Join(t.TempDir(), "missing", "backup.env"), []string{"30 21 * * * /usr/local/bin/proxsave"}, bootstrap)
log := out.String()
for _, want := range []string{"Backup schedule: not adopted from cron entry", "backup.env could not be read"} {
if !strings.Contains(log, want) {
t.Fatalf("missing %q; log:\n%s", want, log)
}
}
}
2 changes: 1 addition & 1 deletion cmd/proxsave/config_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ func ensureConfigExists(path string, logger configStatusLogger) error {

// No automatic migration or template creation: require explicit user action.
logger.Warning("Configuration file not found: %s", path)
logger.Warning("Run 'proxsave --install' (alias: proxmox-backup --install) to create a new configuration")
logger.Warning("Run 'proxsave --install' to create a new configuration")
return fmt.Errorf("configuration file is required to continue")
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/proxsave/config_integrity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func TestTheDebugBlockExplainsEveryDecisionItMade(t *testing.T) {
// which write form won, since the two resolve in opposite ways
fmt.Sprintf("CUSTOM_BACKUP_PATHS assigned on lines %d, %d; line %d wins (block form: it replaces everything before it)", customPathLines[0], customPathLines[1], customPathLines[1]),
// the template's own two halves, so the counts above can be reconstructed
"template assigns 191 variables and documents",
"template assigns 192 variables and documents",
} {
if !strings.Contains(logged, want) {
t.Fatalf("missing %q in:\n%s", want, logged)
Expand Down
15 changes: 5 additions & 10 deletions cmd/proxsave/cron_indirect_refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2076,8 +2076,9 @@ func resolveSystemCronPath(path string) string {
// MM HH DOM MON DOW USER COMMAND -> field 7 is the command
// @daily USER COMMAND -> field 3 is the command
//
// Comments and environment assignments are rejected exactly as in the user format, so
// a line like "MAILTO=root" is never mistaken for a command.
// Comments and environment assignment lines are rejected exactly as in the user format,
// so a line like "MAILTO=root" is never mistaken for a command, and an assignment in front
// of the command is stepped over as there (cronCommandWordAt).
func systemCronCommandToken(line string) string {
trimmed := strings.TrimSpace(line)
if trimmed == "" || strings.HasPrefix(trimmed, "#") {
Expand All @@ -2088,15 +2089,9 @@ func systemCronCommandToken(line string) string {
return ""
}
if strings.HasPrefix(fields[0], "@") {
if len(fields) >= 3 {
return fields[2]
}
return ""
}
if len(fields) <= 6 {
return ""
return cronCommandWordAt(fields, 2)
}
return fields[6]
return cronCommandWordAt(fields, 6)
}

// warnIndirectProxsaveCronOnDaemonInstall reports, without touching anything, every
Expand Down
81 changes: 81 additions & 0 deletions cmd/proxsave/cron_migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,87 @@ func TestRepointLegacyCronLines(t *testing.T) {
if changed2 || out2[0] != "0 5 * * * /usr/local/bin/proxsave --backup" {
t.Errorf("no legacy line -> changed=false, unchanged; got changed=%v out=%v", changed2, out2)
}

// The command field is repointed, never the first occurrence of the legacy path on the
// line: a preceding assignment or a later argument naming that path stays byte-identical.
rows := []struct {
name string
line string
want string
changed bool
}{
{
name: "assignment value holding the legacy path before the command",
line: "0 5 * * * TAG=/usr/local/bin/proxmox-backup.old /usr/local/bin/proxmox-backup --backup",
want: "0 5 * * * TAG=/usr/local/bin/proxmox-backup.old /usr/local/bin/proxsave --backup",
changed: true,
},
{
name: "quoted assignment and quoted command",
line: `0 5 * * * TAG='/usr/local/bin/proxmox-backup.old' "/usr/local/bin/proxmox-backup" --backup`,
want: `0 5 * * * TAG='/usr/local/bin/proxmox-backup.old' "/usr/local/bin/proxsave" --backup`,
changed: true,
},
{
name: "nickname schedule with an assignment",
line: "@daily TAG=/usr/local/bin/proxmox-backup.old /usr/local/bin/proxmox-backup --backup",
want: "@daily TAG=/usr/local/bin/proxmox-backup.old /usr/local/bin/proxsave --backup",
changed: true,
},
{
name: "irregular whitespace is preserved",
line: "0 5 * * * TZ=UTC\t/usr/local/bin/proxmox-backup --backup",
want: "0 5 * * * TZ=UTC\t/usr/local/bin/proxsave --backup",
changed: true,
},
{
name: "argument naming the legacy path is left alone",
line: "0 5 * * * /usr/local/bin/proxmox-backup --log /usr/local/bin/proxmox-backup.log",
want: "0 5 * * * /usr/local/bin/proxsave --log /usr/local/bin/proxmox-backup.log",
changed: true,
},
{
// Pins current behaviour: an assignment whose value is the legacy binary answers
// as the command word itself, so the exact-equality guard skips the line.
name: "assignment naming the legacy binary is not repointed",
line: "0 5 * * * A=/usr/local/bin/proxmox-backup /usr/local/bin/proxmox-backup --backup",
want: "0 5 * * * A=/usr/local/bin/proxmox-backup /usr/local/bin/proxmox-backup --backup",
changed: false,
},
}
for _, tc := range rows {
got, gotChanged := repointLegacyCronLines([]string{tc.line})
if gotChanged != tc.changed || got[0] != tc.want {
t.Errorf("%s:\n line %q\n got %q changed=%v\n want %q changed=%v",
tc.name, tc.line, got[0], gotChanged, tc.want, tc.changed)
}
}
}

// cronFieldOffset finds the first whitespace-separated field equal to the word, splitting
// like strings.Fields, and never a substring inside a longer field.
func TestCronFieldOffset(t *testing.T) {
cases := []struct {
line string
word string
want int
}{
{"0 5 * * * /usr/local/bin/proxmox-backup --backup", "/usr/local/bin/proxmox-backup", 10},
{"0 5 * * * TAG=/usr/local/bin/proxmox-backup.old /usr/local/bin/proxmox-backup", "/usr/local/bin/proxmox-backup", 48},
{"0 5 * * * /x/proxmox-backup.log", "/x/proxmox-backup", -1},
{"a\tb\u00a0c d", "c", 5},
{"a\tb\u00a0c d", "d", 8},
{" lead", "lead", 2},
{"word", "word", 0},
{"a b", "", -1},
{"", "a", -1},
{"ab abc", "abc", 3},
}
for _, tc := range cases {
if got := cronFieldOffset(tc.line, tc.word); got != tc.want {
t.Errorf("cronFieldOffset(%q, %q) = %d, want %d", tc.line, tc.word, got, tc.want)
}
}
}

// The cron line pins the run to the config the daemon or the install used when it is
Expand Down
32 changes: 28 additions & 4 deletions cmd/proxsave/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,11 @@ type daemon struct {
notifyWant *notifyPolicy
notifyApplied *notifyPolicy
notifyPolls uint64 // config polls that reached the relay; guarded by mu
// initialEmailWant is HEALTHCHECK_ACCOUNT_INITIAL_EMAIL as last read by refreshNotifyPolicy
// (nil: d.cfg's). initialEmailDone is the address the relay gave a final answer for
// (applied or rejected): it is not sent again while the variable holds it. Both guarded by mu.
initialEmailWant *string
initialEmailDone string
// pollMu makes the daemon send one /api/healthcheck/config poll at a time (pollCentralized
// holds it across the request and its resends). The relay provisions under a per-server
// lock it does not wait on: a second poll that arrives while the first is provisioning
Expand All @@ -158,6 +163,9 @@ type daemon struct {
pollMu sync.Mutex
// notifyRefreshWaitOverride replaces notifyPolicyRefreshWait in tests.
notifyRefreshWaitOverride time.Duration
// beforeRunPollFinished, when set (tests), is called once a before-run poll's goroutine
// has closed its done channel (refreshNotifyPolicy).
beforeRunPollFinished func()
// confirmedCadence is the seam the relay negotiation of SCHEDULER_FREQUENCY plugs into
// (todo points 17-22 and 39-40): in centralized mode it returns the cadence in effect for
// the configured one, i.e. the one the ProxSave HC Server has confirmed. nil means nothing
Expand Down Expand Up @@ -780,7 +788,7 @@ func (d *daemon) runOnce(parentCtx context.Context) bool {

// Before the start ping, so its bounded wait is not counted in the run duration the remote
// monitor measures, and before getReporter, so a renegotiated channel set is the one pinged.
d.refreshNotifyPolicy(parentCtx)
lateEmail := d.refreshNotifyPolicy(parentCtx)
r := d.getReporter()
rid := health.NewRunID()
d.reportBestEffort("start", false, func() error { return d.startPing(parentCtx, r, rid) })
Expand Down Expand Up @@ -850,6 +858,9 @@ func (d *daemon) runOnce(parentCtx context.Context) bool {
return false
}
logging.Info("daemon: backup finished (rid=%s exit=%d)", rid, code)
// A portal initial email answer that missed the bounded wait before the run is shown here,
// in the same run, or not at all (it is sent again before the next run).
d.logLateInitialEmailOutcome(lateEmail)
// A run whose child actually RAN can lift an inherited abandon degrade: the daemon launched
// a child, it took the backup lock the orphan used to hold, and it was reaped. That is what
// the marker's claim is checked against -- not a skip (ExitBackupSkipped, handled above, is
Expand Down Expand Up @@ -2113,7 +2124,9 @@ func (d *daemon) buildReporter(ctx context.Context) *health.Reporter {
// centralized
p := d.pollCentralized(ctx, "", "")
d.afterFailedPoll(p)
return d.reporterFromPoll(p, false)
r := d.reporterFromPoll(p, false)
d.logInitialEmailOutcome(p)
return r
}

// afterFailedPoll clears the relay secret a poll was refused with. A DEFINITIVE rejection means
Expand Down Expand Up @@ -2200,6 +2213,10 @@ type configPoll struct {
secret string // the exact secret sent, the comparand of a rejected-secret clear
frequency cron.Frequency // the schedule frequency sent
notify notifyPolicy // the notify policy whose ack cfg carries
// initialEmail is the HEALTHCHECK_ACCOUNT_INITIAL_EMAIL the poll carried ("" when none); cfg
// then holds the relay's answer in AccountInitialEmail. It is kept only so that the answer is
// recorded once it is logged (logInitialEmailOutcome), and never logged.
initialEmail string
}

// relaySecret is the relay secret on disk or, when there is none yet, one from a THROTTLED,
Expand Down Expand Up @@ -2245,17 +2262,24 @@ func (d *daemon) pollCentralizedTo(ctx context.Context, logger *logging.Logger,
// checks back to daily on a poll with channels and no frequency.
want := d.wantedNotifyPolicy()
freq := d.wantedFrequency()
// The portal's initial email rides the start poll and the poll before each run, the two that
// report it (logInitialEmailOutcome); the schedule negotiation's polls do not carry it.
initialEmail := ""
if op != "schedule" {
initialEmail = d.wantedInitialEmail()
}
fetch := func(want notifyPolicy) (health.CentralizedConfig, int, error) {
plog := health.PollLog{}
if op != "" {
plog = health.PollLog{Logger: logger, Operation: op, Prefix: prefix,
URLDetail: fmt.Sprintf("frequency=%s notify_on=%s channels=%s", freq, want.notifyOn, want.channelList())}
}
return health.FetchCentralizedConfigPoll(ctx, nil, d.cfg.ServerAPIHost, d.cfg.ServerID, secret,
want.channels, want.notifyOn, string(freq), plog)
want.channels, want.notifyOn, string(freq), initialEmail, plog)
}
cfg, status, err := fetch(want)
p := configPoll{sent: true, status: status, cfg: cfg, err: err, secret: secret, frequency: freq, notify: want}
p := configPoll{sent: true, status: status, cfg: cfg, err: err, secret: secret, frequency: freq, notify: want,
initialEmail: initialEmail}
if err != nil {
return p
}
Expand Down
Loading
Loading