Repository navigation
Conversation
…'t send CreateBucket `rclone copyto` of a single new file sends S3 CreateBucket before the upload, which keys scoped to one bucket are denied. Every backup on such a remote then stopped with "metadata.json could not be uploaded" after the data was already up. `rclone copy --include /metadata.json <dir> <remote>` lists the backup dir like the data step does, so no CreateBucket, and uploads only metadata.json, still last. `copy --include` exits 0 when nothing matches, where `copyto` failed, so a missing local metadata.json is now checked first and reported as a filesystem error (3006). Like a failed metadata upload, it keeps the uploaded files. `--error-on-no-transfer` would also catch it but needs rclone 1.52, and EE requires no minimum rclone version.
…json Retention purged every older folder without metadata.json as an interrupted upload. Backups whose metadata.json upload failed after all data had arrived (every run on a bucket-scoped S3 key since the metadata upload switched to `copyto`) were deleted by the first run that succeeded again. Now only a folder without the site archive is purged as interrupted. One that has the archive but no metadata.json is kept, not counted toward no-of-backups, and named in a warning, since list and restore skip it. Listing and restore still treat it as incomplete.
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
Supersedes #548.
Problem
Since #527 (v4.14.0),
rclone_upload()uploads the data withrclone copy --exclude /metadata.jsonand then metadata.json withrclone copyto. For a single new file,copytosends S3CreateBucket(PUT /<bucket>) before the upload. A key scoped to one bucket is denied that call, so on those remotes every backup ends with "Backup files were uploaded to ..., but metadata.json could not be uploaded". The data step lists the backup dir first, so rclone treats the bucket as existing and never sendsCreateBucket. That is why the data uploads and only metadata.json fails.Listing and restore then skip the folder as incomplete, and retention treats it as an interrupted upload: the first later run that succeeds purges every one of those folders, although their data is complete.
Change
Upload: metadata.json goes up with
rclone copy --include /metadata.json <dir> <remote>. It lists the backup dir like the data step, so noCreateBucket, and it uploads only metadata.json, still after the data. It doesn't depend on the backend type, so on-the-fly remotes and other bucket backends behave the same.copy --includeexits 0 when nothing matches (the oldcopytofailed), so EE first checks that the local metadata.json exists. A missing file is reported as a filesystem error (filesystem_error, code 3006) and keeps the uploaded files, instead of reporting success for a folder that listing and restore skip. rclone's--error-on-no-transferwould also catch it, but it only exists from rclone 1.52.0 and EE doesn't require a minimum rclone version. A failed metadata upload takes the same error path as before.Retention:
cleanup_old_backups()purges as an interrupted upload only an older folder that lacks the site archive. A folder that has the archive but no metadata.json is kept, doesn't count towardno-of-backups, and is named in a warning:Listing and restore are unchanged: they still skip such a folder.
Users who hit this can also add
no_check_bucket = trueto the remote in rclone.conf until they update. On the current code, though, the first backup that then succeeds purges the earlier folders that lack metadata.json, so copy any of those folders they want to keep elsewhere first.Testing
The real
rclone_upload()andcleanup_old_backups()run with only the EE API stubbed, so the exact rclone commands run with a real rclone, on rclone 1.51.0, 1.60.1 and 1.75.1, against two remotes: an S3 mock (SeaweedFS 3.80) with a key that has Read/Write/List on bucketbackupsonly (no Admin, soCreateBucketreturns 403; checked first on every version), and a local alias remote like the CI setup. Requests are logged with--dump headers.Old code (
copyto), rclone 1.60.1, S3 mock:rclone 1.75.1 fails the same way (
operation error S3: CreateBucket ... StatusCode: 403). rclone 1.51.0 also sendsPUT /backupsbut ignores the 403.New code, rclone 1.60.1, S3 mock:
No
PUT /backupsin either step on any of the three rclone versions, and the remote ends up with the data and metadata.json.Missing local metadata.json (both remotes, all three versions):
No rclone command runs for metadata.json, nothing is purged and the data stays on the remote. With the local check removed,
copy --includeexits 0 on all three versions and EE reports success, so the check is what keeps this an error.Retention: older folders seeded with a complete backup, one with the site archive and SQL but no metadata.json, and one with only the SQL; then a full upload with
no-of-backups: 2:The only purge is the folder without the archive; the complete older backup stays, which it wouldn't if the archive-only folder counted toward the limit. The current code purges the archive-only folder too.
All cases pass on PHP 8.5 and 7.4;
php -lpasses on both.Summary by CodeRabbit