Skip to content

Application Aware Backups truncate database dumps 100M+ #1109

@ahyattdev

Description

@ahyattdev

Description

  annotations:
    k8up.io/backupcommand: bash -c 'set -euo pipefail; PGDATABASE="app" pg_dump --clean > /run/tmp/backup.sql; cat /run/tmp/backup.sql'
    k8up.io/file-extension: .sql

I first send the write to a file to ensure that the truncation isn't being done before k8up can see the output. The file at /run/tmp/backup.sql is complete, ending like this:

--
-- PostgreSQL database dump complete
--

The complete DB dump is 343MB on disk.

But the actually backed up file is incomplete at 340MB.

This suggests a bug when handling the final chunks of stdout from an Application Aware Backup.

The pre backup pod in K8up has no errors or indicators that these commands failed.

Additional Context

No response

Logs

[2026-03-07  08:33:14]	2026-03-07T13:33:14Z	INFO	k8up	Starting k8up…	{"version": "2.13.1", "date": "2025-10-03T07:31:20Z", "commit": "56ca1a38786778474be6260d7c90f65e40a3eff8", "go_os": "linux", "go_arch": "amd64", "go_version": "go1.23.12", "uid": 8888, "gid": 8888}
[2026-03-07  08:33:14]	2026-03-07T13:33:14Z	INFO	k8up.restic	initializing
[2026-03-07  08:33:14]	2026-03-07T13:33:14Z	INFO	k8up.restic	setting up a signal handler
[2026-03-07  08:33:14]	2026-03-07T13:33:14Z	INFO	k8up.restic	sleeping until init	{"duration": "3s"}
[2026-03-07  08:33:17]	2026-03-07T13:33:17Z	INFO	k8up.restic.restic.RepoInit.command	restic command	{"path": "/usr/local/bin/restic", "args": ["init"]}
[2026-03-07  08:33:17]	2026-03-07T13:33:17Z	INFO	k8up.restic.restic.RepoInit.command	Defining RESTIC_PROGRESS_FPS	{"frequency": 0.016666666666666666}
[2026-03-07  08:33:17]	2026-03-07T13:33:17Z	INFO	k8up.restic.restic.unlock	unlocking repository	{"all": false}
[2026-03-07  08:33:17]	2026-03-07T13:33:17Z	INFO	k8up.restic.restic.unlock.command	restic command	{"path": "/usr/local/bin/restic", "args": ["unlock"]}
[2026-03-07  08:33:17]	2026-03-07T13:33:17Z	INFO	k8up.restic.restic.unlock.command	Defining RESTIC_PROGRESS_FPS	{"frequency": 0.016666666666666666}
[2026-03-07  08:33:21]	2026-03-07T13:33:21Z	INFO	k8up.restic.restic.snapshots	getting list of snapshots
[2026-03-07  08:33:21]	2026-03-07T13:33:21Z	INFO	k8up.restic.restic.snapshots.command	restic command	{"path": "/usr/local/bin/restic", "args": ["snapshots", "--json"]}
[2026-03-07  08:33:21]	2026-03-07T13:33:21Z	INFO	k8up.restic.restic.snapshots.command	Defining RESTIC_PROGRESS_FPS	{"frequency": 0.016666666666666666}
[2026-03-07  08:43:56]	2026-03-07T13:43:56Z	INFO	k8up.restic.k8sClient	listing all pods	{"annotation": "k8up.io/backupcommand", "namespace": "rss"}
[2026-03-07  08:43:56]	2026-03-07T13:43:56Z	INFO	k8up.restic.k8sClient	adding to backup list	{"namespace": "rss", "pod": "rss-database-1"}
[2026-03-07  08:43:56]	2026-03-07T13:43:56Z	INFO	k8up.restic.k8sExec	executing command	{"command": "bash, -c, set -euo pipefail; PGDATABASE=\"app\" pg_dump --clean > /run/tmp/backup.sql; cat /run/tmp/backup.sql", "namespace": "rss", "pod": "rss-database-1"}
[2026-03-07  08:43:56]	2026-03-07T13:43:56Z	INFO	k8up.restic.restic.stdinBackup	starting stdin backup	{"filename": "/rss-postgres", "extension": ".sql"}
[2026-03-07  08:43:56]	2026-03-07T13:43:56Z	INFO	k8up.restic.restic.stdinBackup.command	restic command	{"path": "/usr/local/bin/restic", "args": ["backup", "--stdin-filename", "/rss-postgres.sql", "--host", "rss", "--json", "--stdin"]}
[2026-03-07  08:43:56]	2026-03-07T13:43:56Z	INFO	k8up.restic.restic.stdinBackup.command	Defining RESTIC_PROGRESS_FPS	{"frequency": 0.016666666666666666}
[2026-03-07  08:48:51]	2026-03-07T13:48:51Z	INFO	k8up.restic.restic.stdinBackup.progress	backup finished	{"new files": 1, "changed files": 0, "errors": 0}
[2026-03-07  08:48:51]	2026-03-07T13:48:51Z	INFO	k8up.restic.restic.stdinBackup.progress	stats	{"time": 290.991614567, "bytes added": 244525209, "bytes processed": 355663872}
[2026-03-07  08:48:51]	2026-03-07T13:48:51Z	INFO	k8up.restic.restic.MountCollector	stats mount dir doesn't exist, skipping stats	{"dir": "/data"}
[2026-03-07  08:48:51]	2026-03-07T13:48:51Z	INFO	k8up.restic.statsHandler.promStats	sending prometheus stats	{"url": "http://prometheus-prometheus-pushgateway.prometheus.svc.cluster.local:9091"}
[2026-03-07  08:48:52]	2026-03-07T13:48:52Z	INFO	k8up.restic	backups of annotated jobs have finished successfully
[2026-03-07  08:48:52]	2026-03-07T13:48:52Z	INFO	k8up.restic.restic.backup	starting backup
[2026-03-07  08:48:52]	2026-03-07T13:48:52Z	INFO	k8up.restic.restic.backup	backupdir does not exist, skipping. Sending snapshot list	{"dirname": "/data"}
[2026-03-07  08:48:52]	2026-03-07T13:48:52Z	INFO	k8up.restic.restic.snapshots	getting list of snapshots
[2026-03-07  08:48:52]	2026-03-07T13:48:52Z	INFO	k8up.restic.restic.snapshots.command	restic command	{"path": "/usr/local/bin/restic", "args": ["snapshots", "--json"]}
[2026-03-07  08:48:52]	2026-03-07T13:48:52Z	INFO	k8up.restic.restic.snapshots.command	Defining RESTIC_PROGRESS_FPS	{"frequency": 0.016666666666666666}

Expected Behavior

The Application Aware Backup is contains 100% of the data outputted by the backup command.

Steps To Reproduce

No response

Version of K8up

v4.8.6

Version of Kubernetes

v1.33.5+rke2r1

Distribution of Kubernetes

RKE2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions