nixys / nxs-backup

The tool for creating, delivering and rotating backups for GNU/Linux distributions.
https://nxs-backup.io
Apache License 2.0
255 stars 13 forks source link

panic: runtime error: invalid memory address or nil pointer dereference #51

Closed Donedjes closed 4 months ago

Donedjes commented 4 months ago

Hello. Running latest nxs-backup 3.8.0. When I try validate my cnf I get the following errors:

# nxs-backup --version
nxs-backup 3.8.0
# nxs-backup -t
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0xd59863]

goroutine 1 [running]:
github.com/nixys/nxs-backup/modules/metrics.(*Data).GetMetrics(...)
        /home/runner/work/nxs-backup/nxs-backup/modules/metrics/metrics.go:81
github.com/nixys/nxs-backup/modules/backup/psql.Init({{0xc000477350, 0xe}, {0xc000036ed0, 0x18}, 0x1, 0x0, 0x0, 0x0, {0xc00033fd50, 0x1, ...}, ...})
        /home/runner/work/nxs-backup/nxs-backup/modules/backup/psql/psql.go:97 +0x2a3
github.com/nixys/nxs-backup/ctx.jobsInit({0x0, 0x0, 0x0, {0xc00020eab0, 0x1, 0x1}, 0xc00035f200})
        /home/runner/work/nxs-backup/nxs-backup/ctx/jobs_init.go:276 +0x22f8
github.com/nixys/nxs-backup/ctx.appInit(0x3?, {0x103a1fb, 0x1f})
        /home/runner/work/nxs-backup/nxs-backup/ctx/context.go:210 +0x65a
github.com/nixys/nxs-backup/ctx.AppCtxInit()
        /home/runner/work/nxs-backup/nxs-backup/ctx/context.go:96 +0xa93
github.com/nixys/nxs-go-appctx/v3.(*AppCtx).Run(0xc0004e8d20)
        /home/runner/go/pkg/mod/github.com/nixys/nxs-go-appctx/v3@v3.0.0/appctx.go:65 +0x42
main.main()
        /home/runner/work/nxs-backup/nxs-backup/main.go:38 +0x4f5

My nxs-backup.conf:

project_name: PROJECT
server_name: postgresql

server:
  metrics:
    enabled: false

loglevel: debug

notifications:
  mail:
    enabled: false
  webhooks:
    - webhook_url: "SOME URL"
      message_level: "warning"
      extra_headers:
        "X-Auth-Key": "SOME KEY"
      payload_message_key: "triggerMessage"
      extra_payload:
        "isEmergencyAlert": false
        "rawTriggerMessage": false
        "monitoringURL": "-"

include_jobs_configs: ["conf.d/*.conf"]

When I commented out the metrics:

#server:
#  metrics:
#    enabled: false

I received the following error:

# nxs-backup -t
Failed to init metrics: open /tmp/nxs-backup.metrics: permission denied

Fixed by:

chown root: /tmp/nxs-backup.metrics
# nxs-backup -t
The configuration is correct

No external jobs
List of databases jobs:
  postgresql
No files jobs
randreev1321 commented 4 months ago

Hi @Donedjes.

Thanks for your interest in nxs-backup.

This issue has been fixed in version 3.8.1.

New ideas and suggestions are welcome.