nextcloud / nextcloud/nextcloudpi
nc-backup reports "error generating backup" although backup archive is successfully created when using external data directory
Nobody has claimed this yet.
- Dominant language
- Shell
- Stars
- 2.9k
- Forks
- 318
- PR merge metrics
- No merged PRs in 30d
Description
Note:
I can reproduce this consistently when the Nextcloud data directory is located on an external drive (/media/.../ncdata/data) and a full backup including data is created from the NextcloudPi Web UI.
Additional information
The generated archive is approximately 279 GB and is readable with:
tar -tvf nextcloud-bkp_20260729_1785329521.tar
The SQL dump and all user data are present.
Therefore the backup itself appears to be successful, while the script reports a failure because GNU tar returns a warning exit code.
nc-backup reports failure although backup archive is successfully created when using an external data directory
Environment
- NextcloudPi: v1.58.0
- Debian 12 (Bookworm)
- Raspberry Pi 4
- Nextcloud data directory located on an external Btrfs volume:
/media/myCloudDrive/ncdata/data - Backup destination:
/media/myCloudDriveBackups/ncp-backups
Summary
Creating a full backup including user data from the NextcloudPi Web UI reports
error generating backup
although the backup archive is successfully created and appears to be complete.
Steps to reproduce
- Configure an external Nextcloud data directory.
- Start nc-backup from the NextcloudPi Web UI.
- Enable Include data.
- Wait until the backup finishes.
Actual result
The backup log ends with:
backup database...
backup files...
tar: data/nextcloud.log: file changed as we read it
error generating backup
Maintenance mode disabled
The Web UI reports the backup as failed.
Expected result
The backup should either
- complete successfully, or
- report the
tarwarning without marking the backup as failed.
Verification performed
The generated archive exists:
nextcloud-bkp_20260729_1785329521.tar
Archive size:
279 GB
The archive is readable:
tar -tvf nextcloud-bkp_20260729_1785329521.tar | head
Output starts with:
nextcloud-sqlbkp_20260729.bak
data/
data/.ncdata
data/klaus/...
The SQL dump is present and the data directory contents are included.
The backup therefore appears to have completed successfully.
Additional observations
The backup script (/usr/local/bin/ncp-backup) contains:
tar ... \
|| {
echo "error generating backup"
exit 1
}
This treats every non-zero exit status from GNU tar as a fatal error.
However, GNU tar documents the following exit codes:
- 0 = Success
- 1 = Warnings
- 2 = Fatal error
The observed message
tar: data/nextcloud.log: file changed as we read it
is typically associated with a warning (exit status 1), while the archive itself is still valid.
Possible issue with the exclude pattern
The script excludes
--exclude "nextcloud/data/nextcloud.log"
When the data directory is external, the archived path appears to be
data/nextcloud.log
instead of
nextcloud/data/nextcloud.log
which may explain why nextcloud.log is still archived and triggers the warning.
Suggested improvement
Consider:
- accepting GNU tar exit code 1 as a warning instead of a fatal backup failure, and/or
- adjusting the exclude rule so that
nextcloud.logis excluded correctly when the data directory is located outside the Nextcloud installation.
Additional note
I can reproduce this consistently when the Nextcloud data directory is stored on an external drive (/media/.../ncdata/data) and a full backup including data is started from the NextcloudPi Web UI.
The generated archive is complete, readable and significantly larger than previous backups, suggesting that only the backup status reporting is incorrect.
PS: I have this entire incident with ChatGPD developed and created. I hope it helps. (Otherwise, I know that nobody likes smartarses)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with /usr/local/bin/ncp-backup and reproduce a full data backup from the NextcloudPi Web UI using an external data directory. Inspect the tar command, its exclude pattern, and how exit statuses are handled. Done means a valid archive with the observed warning is not reported as failed, while genuine fatal errors still are.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- shell
- Domain
- devops
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100