Skip to content

[Bug]: backup command of the cnpg plugin using local time zone #11328

Description

@gbartolini

Is there an existing issue already for this bug?

  • I have searched for an existing issue, and could not find anything. I believe this is a new bug.

I have read the troubleshooting guide

  • I have read the troubleshooting guide and I think this is a new bug.

I am running a supported version of CloudNativePG

  • I have read the troubleshooting guide and I think this is a new bug.

Contact Details

No response

Version

1.30.0

What version of Kubernetes are you using?

1.36

What is your Kubernetes environment?

Self-managed: kind (evaluation)

How did you install the operator?

YAML manifest

What happened?

Currently, the cnpg backup plugin names backup objects using a timestamp that relies on the client local time zone. However, internally, the backupId is then transformed in the UTC time zone format.

I think we should standardise and always use UTC time zone even in this case.

Cluster resource

Relevant log output

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added this to the 1.30.1 milestone on Aug 15, 2026
  2. self-assigned this
    on Aug 15, 2026
  3. added
    bug 🐛
    triage
    on Aug 15, 2026
  4. dosubot commented on Aug 15, 2026

    @dosubot

    The root cause is in internal/cmd/plugin/backup/cmd.go, where the backup name is generated using:

    backupName = fmt.Sprintf("%s-%s", clusterName, pgTime.ToCompactISO8601(time.Now()))

    [1]

    time.Now() returns the current time in the local system timezone, and ToCompactISO8601 simply formats it with t.Format("20060102150405"), preserving whatever timezone the time.Time value carries. So on a client machine with a non-UTC timezone, the backup name timestamp will diverge from the server-side backupId after UTC normalization.

    The fix is a one-line change — pass time.Now().UTC() instead of time.Now():

    backupName = fmt.Sprintf("%s-%s", clusterName, pgTime.ToCompactISO8601(time.Now().UTC()))

    To reply, just mention @dosu.


    Share context across your team and agents. Try Dosu.

    Leave Feedback Learn about cloudnative-pg with Dosu Add Dosu to your team

  5. added a commit that references this issue on Aug 15, 2026
    011ba50
  6. added 3 commits that reference this issue on Aug 15, 2026
    d408ca6
    e0409a2
    0d6ce13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug 🐛triage

Type

Projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions