# Does --immutable prevent overwriting modified files during copy?

**URL:** <https://forum.rclone.org/t/does-immutable-prevent-overwriting-modified-files-during-copy/51167>\
**Category:** Help and Support\
**Created:** [May 10, 2025, 7:43pm UTC](https://forum.rclone.org/t/does-immutable-prevent-overwriting-modified-files-during-copy/51167 "2025-05-10T19:43:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kekobond](https://forum.rclone.org/user_avatar/forum.rclone.org/kekobond/32/19724_2.png) [@kekobond](https://forum.rclone.org/u/kekobond)\
**Post date:** [May 10, 2025, 7:43pm UTC](https://forum.rclone.org/t/does-immutable-prevent-overwriting-modified-files-during-copy/51167/1 "2025-05-10T19:43:33Z")

</div>

Hi all,

I'm trying to better understand how the `--immutable` flag works in practice.

Let's say I use `rclone copy` to copy `file.txt` from my local source to a remote destination. The file is successfully copied.

Later, I modify `file.txt` on the source and run the same `rclone copy` command again, this time with the `--immutable` flag enabled.

My expectation is that rclone should detect that `file.txt` on the destination has already been modified (i.e. it differs from the source) and then **fail with an error or warning** —and importantly, it should **not replace** the existing file.

Is this the correct behavior of `--immutable`?

Also, is there a difference between `--immutable` and `--ignore-existing` when it comes to preventing overwrites? I want to ensure that existing files are never modified during a copy operation, even if the source version has changed.

Thanks in advance for the clarification!

---

<div class="post-metadata">

**Author:** ![asdffdsa](https://forum.rclone.org/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@asdffdsa](https://forum.rclone.org/u/asdffdsa)\
**Post date:** [May 10, 2025, 8:03pm UTC](https://forum.rclone.org/t/does-immutable-prevent-overwriting-modified-files-during-copy/51167/2 "2025-05-10T20:03:45Z")

</div>

> [@kekobond](#):
>
> Later, I modify `file.txt` on the source and run the same `rclone copy` command again, this time with the `--immutable` flag enabled.
> 
> My expectation is that rclone should detect that `file.txt` on the destination has already been modified (i.e. it differs from the source) and then **fail with an error or warning** —and importantly, it should **not replace** the existing file.

you expectation is correct.

sometimes a simple test is the best way to understand.

```auto
# setup the test environment
mkdir -p ~/src
mkdir -p ~/dst

#create source file
touch ~/src/file.ext

# copy file.ext from source to dest
cp ~/src/ ~/dst/ -v

```

```auto
# using `--immutable`. rclone will not overwrite dest file and trigger an `ERROR`

touch ~/src/file.ext

rclone copy ~/src ~/dst --immutable -vv
ERROR : file.ext: Timestamp mismatch between immutable objects
ERROR : file.ext: Source and destination exist but do not match: immutable file modified

```

> [@kekobond](#):
>
> I want to ensure that existing files are never modified during a copy operation, even if the source version has changed.

```auto
# using `--ignore-existing`, rclone will not modify/overwrite dest file as it already exists.
touch ~/src/file.ext

rclone copy ~/src ~/dst --ignore-existing -vv
DEBUG : file.ext: Destination exists, skipping
INFO : There was nothing to transfer

```

---

<div class="post-metadata">

**Author:** ![kapitainsky](https://forum.rclone.org/user_avatar/forum.rclone.org/kapitainsky/32/14450_2.png) [@kapitainsky](https://forum.rclone.org/u/kapitainsky)\
**Post date:** [May 10, 2025, 8:05pm UTC](https://forum.rclone.org/t/does-immutable-prevent-overwriting-modified-files-during-copy/51167/3 "2025-05-10T20:05:51Z")

</div>

Check [docs](https://rclone.org/docs/) for details but the key difference is that

1. with `--immutable` files will be created and deleted as requested, but existing files will never be updated
2. with `--ignore-existing` unconditionally skip all files that exist on the destination, no matter the content of these files.

So the former can delete a file at destination when the latter not.

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [June 9, 2025, 8:06pm UTC](https://forum.rclone.org/t/does-immutable-prevent-overwriting-modified-files-during-copy/51167/4 "2025-06-09T20:06:37Z")

</div>

Closed on June 9, 2025, 8:06pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
