Skip to content

nc-backup reports "error generating backup" although backup archive is successfully created when using external data directory #2130

Description

@ksitta-git

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

  1. Configure an external Nextcloud data directory.
  2. Start nc-backup from the NextcloudPi Web UI.
  3. Enable Include data.
  4. 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 tar warning 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.log is 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions