brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: rclone copy --immutable refuses to overwrite or delete anything at the destination

Rclone
~/tips/tip-backup-rclone-immutable-no-overwrite

rclone copy --immutable /mnt/user/appdata/<app>/exports remote:archive

Makes an rclone copy add new files but never overwrite or delete the ones already at the destination.

For an archive folder that should only ever grow, rclone sync is the wrong tool and even rclone copy will happily replace a file that changed on the source. One flag makes the destination write-once.

rclone copy --immutable /mnt/user/appdata/<app>/exports remote:archive

With --immutable, rclone treats source and destination files as immutable. New files are created as usual, but an existing file is never updated. If an existing file differs between the two sides, rclone does not touch it and gives the error Source and destination exist but do not match: immutable file modified. That error is your early warning that something changed a file you expected to stay as it was, for example a document that was edited after it was archived, or a file that got damaged.

The docs are careful about the difference between commands. The flag only affects commands that transfer files, such as sync, copy and move, and it only forbids modification. With sync or move files can still be deleted, and delete or purge still work. The docs give the way out: use copy --immutable if you want to avoid deletion as well as modification. That is why my example uses copy.

The caveat is that nothing on this destination ever gets updated, so a legitimate change, such as a corrected export, will fail with the same error. You then have to decide yourself: store the new version under a new name, or remove the old file on purpose. That friction is the point for an archive, and a nuisance for anything that changes often. For a folder that changes, --backup-dir is the better fit, since it keeps the older version aside.

Further reading: rclone documentation: global flags (–immutable)

More Rclone tips rclone copyurl https://example.com/files/big.iso remote:isos -a rclone size remote:photos rclone config redacted rclone ncdu remote:backup rclone copy /data remote:data --bwlimit "08:00,1M 18:00,5M 23:00,off" -P All Rclone tips (14) All topics

Link