# Immutability feature for randsomware protection. S3 / B2 'Object Lock' or application keys without deleteFiles permission

**URL:** <https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136>\
**Category:** Features\
**Created:** [November 14, 2020, 9:09am UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136 "2020-11-14T09:09:28Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![fred](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/f/db5fbb/32.png) [@fred](https://forum.duplicati.com/u/fred)\
**Post date:** [November 14, 2020, 9:09am UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/1 "2020-11-14T09:09:28Z")

</div>

An idea. To protect against malicious attacks it would be great _if our backup jobs cannot delete files_. For someone with malicous intent takes control of the machine running Duplicati, backup data can be corrupted (e.g. source paths and exclude filters changed, remote files deleted or altered).

Two approaches come to mind:  
**1) BackupOnly application keys**  
We could create b2 keys that do not have the **deleteFiles** ability and use bucket lifecycle settings in b2 to delete files older than a desired number of days.  
e.g.  
`b2 create-key --bucket bucketname --namePrefix duplicati BackupOnly listBuckets,listFiles,readFiles,shareFiles,writeFiles`  
refer to: [Application Keys](https://www.backblaze.com/b2/docs/application_keys.html)

**2) Immutability feature**  
**Object Lock** , a feature recently released in Backblaze b2 for Veeam (backup software) allows you to set the time for which a file is immutable. One could set a period of, say, 1 year.  
refer to: [Object Lock FAQs – Backblaze Help](https://help.backblaze.com/hc/en-us/articles/360052973274-Object-Lock-FAQs)

Feature request:  
**As an** enduser concerned with randsomware and other malicious hacking activities,  
**I would like to** prevent duplicati from being able to delete files,  
**So that** an adversary cannot corrupt backups.

NB The backblaze account would have to be protected by multi-factor authentication to prevent an adversary to simply terminate your b2 account.

---

<div class="post-metadata">

**Author:** ![fred](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/f/db5fbb/32.png) [@fred](https://forum.duplicati.com/u/fred)\
**Post date:** [November 14, 2020, 9:24am UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/2 "2020-11-14T09:24:56Z")

</div>

Please view a github feature request here (probably a better place to discusse this): [Feature request: immutability feature for randsomware protection. S3 / B2 'Object Lock' or application keys without deleteFiles permission · Issue #4364 · duplicati/duplicati · GitHub](https://github.com/duplicati/duplicati/issues/4364)

---

<div class="post-metadata">

**Author:** ![drwtsn32](https://forum.duplicati.com/user_avatar/forum.duplicati.com/drwtsn32/32/2591_2.png) [@drwtsn32](https://forum.duplicati.com/u/drwtsn32)\
**Post date:** [November 14, 2020, 5:31pm UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/3 "2020-11-14T17:31:59Z")

</div>

You can prohibit deletion on the back end if you do two things:

- Use unlimited retention
- Set the [`--no-auto-compact`](https://duplicati.readthedocs.io/en/latest/06-advanced-options/#no-auto-compact) option to True

---

<div class="post-metadata">

**Author:** ![ts678](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@ts678](https://forum.duplicati.com/u/ts678)\
**Post date:** [November 16, 2020, 12:25am UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/4 "2020-11-16T00:25:49Z")

</div>

> [@fred](#):
>
> use bucket lifecycle settings in b2 to delete files older than a desired number of days.

That will probably break your backup because data blocks remain in use in current files.  
Duplicati uploads file changes as they are found, but unchanged data is just cited again.

[Features](https://duplicati.readthedocs.io/en/latest/01-introduction/#features) (see `Incremental backups` and `Deduplication`)  
[How the backup process works](https://duplicati.readthedocs.io/en/latest/appendix-a-how-the-backup-process-works/)  
[Compacting files at the backend](https://duplicati.readthedocs.io/en/latest/03-using-the-graphical-user-interface/#compacting-files-at-the-backend) (which you can’t do, as it deletes the compacted files)  
[The COMPACT command](https://duplicati.readthedocs.io/en/latest/04-using-duplicati-from-the-command-line/#the-compact-command) (more details – it’s not only version deletes that can do this)

So, as noted, the general plan for this is no version deletes and no automatic compacts.  
One possible remaining delete is hard to avoid, but may or may not bring you problems.  
If a file upload files, the upload is retried using a new name, and the old name is deleted:

[( $50 Bounty ) Attempting deletion of files before retention span is over](https://forum.duplicati.com/t/50-bounty-attempting-deletion-of-files-before-retention-span-is-over/10932)

I’m kind of curious how backup software that can live with immutability manages to do it.  
One simple crude way would be to store multiple full copies of files, but that’s inefficient.

---

<div class="post-metadata">

**Author:** ![drwtsn32](https://forum.duplicati.com/user_avatar/forum.duplicati.com/drwtsn32/32/2591_2.png) [@drwtsn32](https://forum.duplicati.com/u/drwtsn32)\
**Post date:** [November 16, 2020, 4:26am UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/5 "2020-11-16T04:26:15Z")

</div>

> [@ts678](#):
>
> That will probably break your backup

It will _definitely_ break your backup. Don’t use lifecycle settings or versioning on the backend.

---

<div class="post-metadata">

**Author:** ![dgcom](https://forum.duplicati.com/user_avatar/forum.duplicati.com/dgcom/32/2711_2.png) [@dgcom](https://forum.duplicati.com/u/dgcom)\
**Post date:** [November 29, 2020, 12:41am UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/6 "2020-11-29T00:41:53Z")

</div>

> [@ts678](#):
>
> If a file upload files, the upload is retried using a new name, and the old name is deleted

This should be solved on the destination - file should not be marked as completely uploaded unless it is marked as so… Unfortunately, some storage backends keep partially uploaded files so the upload can be resumed…  
I just checked b2\_upload\_file function description for Backblaze and do not see how it might keep partially uploaded file, so this shouldn’t be an issue with B2…

---

<div class="post-metadata">

**Author:** ![ts678](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@ts678](https://forum.duplicati.com/u/ts678)\
**Post date:** [November 29, 2020, 1:52am UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/7 "2020-11-29T01:52:51Z")

</div>

> [@dgcom](#):
>
> I just checked b2\_upload\_file function description for Backblaze and do not see how it might keep partially uploaded file, so this shouldn’t be an issue with B2…

I suspect that cloud services typically don’t keep partially uploaded files, but the question is whether the Duplicati viewpoint sees it as uploading, then a failure happens, then it decides to delete. States run like

> <https://github.com/duplicati/duplicati/blob/7d958adb8a71b334834ce42ecc9571c78e8a259e/Duplicati/Library/Main/Enums.cs#L64-L83>

> [@dgcom](#):
>
> file should not be marked as completely uploaded unless it is marked as so…

Duplicati’s marking scheme is (in part) shown above, and an old (2015) description of the flow is [here](https://github.com/duplicati/duplicati/issues/1243#issuecomment-71367471).

Current code may or may not follow 2015 description, but this is some of the delete-fail recovery logic:

> <https://github.com/duplicati/duplicati/blob/7d958adb8a71b334834ce42ecc9571c78e8a259e/Duplicati/Library/Main/BackendManager.cs#L585-L602>

and ultimately the proof of behavior is what is seen. I’ve seen some unexpected behavior in the above (unable to supply additional details, but I have a failure test program and some run notes somewhere).

[( $50 Bounty ) Attempting deletion of files before retention span is over](https://forum.duplicati.com/t/50-bounty-attempting-deletion-of-files-before-retention-span-is-over/10932) would need to be explained too.  
Without actually seeing the database, it’s not certain what happened, but one known behavior is that at Duplicati backup start, it cleans up files that it was trying to delete on a previous run, i.e. state Deleting.

I actually make use of this to [fix a problem](https://github.com/duplicati/duplicati/issues/4129#issuecomment-659753843) that comes up when Compact is interrupted and it forgets it successfully deleted some dindex files. Doing a database transaction rollback is the suspected cause. Workaround is to set state of the dindex files to `Deleting`, which is what the no-issue dblock files had.

If you’re willing to dig in code more, feel free to take this to GitHub [Issues](https://github.com/duplicati/duplicati/issues) to see if a developer can chat. There’s a major shortage of developers though, so an even better course would be to do a pull request.

There have been several forum user attempts to work with immutable destinations, and possibly even more attempts to work with cold storage, where I’m not sure if the retry delete may present a problem.

> [@dgcom](#):
>
> This should be solved on the destination

The destination does what it does. Duplicati knows a few capability differences, but has to deal with all.

If you want to poke at this more, beyond just reading code, an SQLite browser helps, and I can offer a script to make upload errors, to look at retry handling. That’s the test I tried awhile ago that I mentioned.

---

<div class="post-metadata">

**Author:** ![dgcom](https://forum.duplicati.com/user_avatar/forum.duplicati.com/dgcom/32/2711_2.png) [@dgcom](https://forum.duplicati.com/u/dgcom)\
**Post date:** [November 29, 2020, 2:09am UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/8 "2020-11-29T02:09:54Z")

</div>

> [@ts678](#):
>
> If you want to poke at this more, beyond just reading code, an SQLite browser helps, and I can offer a script to make upload errors, to look at retry handling. That’s the test I tried awhile ago that I mentioned.

Well, if I get time for this, I’ll look, but now this is not a priority. I use Duplicati in some capacity, where I can avoid some shortcomings, but have no time to dig in into older code… Maybe if there is an effort to move to .Net Core…  
But I agree - supporting many different types of storage backends is not an easy task.

---

<div class="post-metadata">

**Author:** ![ts678](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@ts678](https://forum.duplicati.com/u/ts678)\
**Post date:** [November 29, 2020, 3:18am UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/9 "2020-11-29T03:18:47Z")

</div>

I found my old test notes, but an actual production backup log to OneDrive was more useful to show effect.

This is the history of a dindex file which suffered an upload error, got set to `Deleting`, and cleaned up later. Maybe. There’s nothing that shows the actual Backend event: Delete, so maybe it looked before trying that, which in best case means everything is already all set for a no-deletes destination that won’t leave partials.

```plaintext
2020-09-28 18:20:00 -04 - [Information-Duplicati.Library.Main.Controller-StartingOperation]: The operation Backup has started
2020-09-28 18:22:34 -04 - [Profiling-Timer.Begin-Duplicati.Library.Main.Database.ExtensionMethods-ExecuteScalarInt64]: Starting - ExecuteScalarInt64: INSERT INTO "Remotevolume" ("OperationID", "Name", "Type", "State", "Size", "VerificationCount", "DeleteGraceTime") VALUES (123, "duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes", "Index", "Temporary", -1, 0, 0); SELECT last_insert_rowid();
2020-09-28 18:22:34 -04 - [Profiling-Timer.Finished-Duplicati.Library.Main.Database.ExtensionMethods-ExecuteScalarInt64]: ExecuteScalarInt64: INSERT INTO "Remotevolume" ("OperationID", "Name", "Type", "State", "Size", "VerificationCount", "DeleteGraceTime") VALUES (123, "duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes", "Index", "Temporary", -1, 0, 0); SELECT last_insert_rowid(); took 0:00:00:00.005
2020-09-28 18:22:34 -04 - [Information-Duplicati.Library.Main.BasicResults-BackendEvent]: Backend event: Put - Started: duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes (48.62 KB)
2020-09-28 18:23:15 -04 - [Retry-Duplicati.Library.Main.Operation.Backup.BackendUploader-RetryPut]: Operation Put with file duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes attempt 1 of 2 failed with message: Failed to authorize using the OAuth service: Server error. If the problem persists, try generating a new authid token from: https://duplicati-oauth-handler.appspot.com?type=onedrivev2
2020-09-28 18:23:15 -04 - [Information-Duplicati.Library.Main.BasicResults-BackendEvent]: Backend event: Put - Retrying: duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes (48.62 KB)
2020-09-28 18:23:25 -04 - [Information-Duplicati.Library.Main.BasicResults-BackendEvent]: Backend event: Put - Rename: duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes (48.62 KB)
2020-09-28 18:23:25 -04 - [Information-Duplicati.Library.Main.Operation.Backup.BackendUploader-RenameRemoteTargetFile]: Renaming "duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes" to "duplicati-iab6e6b556c3940ad82f7f834baa81b99.dindex.zip.aes"
2020-09-28 18:23:25 -04 - [Profiling-Timer.Begin-Duplicati.Library.Main.Database.ExtensionMethods-ExecuteNonQuery]: Starting - ExecuteNonQuery: UPDATE "Remotevolume" SET "Name" = "duplicati-iab6e6b556c3940ad82f7f834baa81b99.dindex.zip.aes" WHERE "Name" = "duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes"
2020-09-28 18:23:25 -04 - [Profiling-Timer.Finished-Duplicati.Library.Main.Database.ExtensionMethods-ExecuteNonQuery]: ExecuteNonQuery: UPDATE "Remotevolume" SET "Name" = "duplicati-iab6e6b556c3940ad82f7f834baa81b99.dindex.zip.aes" WHERE "Name" = "duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes" took 0:00:00:00.000
2020-09-28 18:23:25 -04 - [Profiling-Timer.Begin-Duplicati.Library.Main.Database.ExtensionMethods-ExecuteScalarInt64]: Starting - ExecuteScalarInt64: INSERT INTO "Remotevolume" ("OperationID", "Name", "Type", "State", "Size", "VerificationCount", "DeleteGraceTime") VALUES (123, "duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes", "Index", "Deleting", -1, 0, 0); SELECT last_insert_rowid();
2020-09-28 18:23:25 -04 - [Profiling-Timer.Finished-Duplicati.Library.Main.Database.ExtensionMethods-ExecuteScalarInt64]: ExecuteScalarInt64: INSERT INTO "Remotevolume" ("OperationID", "Name", "Type", "State", "Size", "VerificationCount", "DeleteGraceTime") VALUES (123, "duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes", "Index", "Deleting", -1, 0, 0); SELECT last_insert_rowid(); took 0:00:00:00.000
2020-09-28 19:20:00 -04 - [Information-Duplicati.Library.Main.Controller-StartingOperation]: The operation Backup has started
2020-09-28 20:20:00 -04 - [Information-Duplicati.Library.Main.Controller-StartingOperation]: The operation Backup has started
2020-09-28 20:20:37 -04 - [Information-Duplicati.Library.Main.Operation.FilelistProcessor-RemoteUnwantedMissingFile]: removing file listed as Deleting: duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes
2020-09-28 20:20:37 -04 - [Profiling-Timer.Begin-Duplicati.Library.Main.Database.ExtensionMethods-ExecuteScalarInt64]: Starting - ExecuteScalarInt64: SELECT "ID" FROM "Remotevolume" WHERE "Name" = "duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes"
2020-09-28 20:20:37 -04 - [Profiling-Timer.Finished-Duplicati.Library.Main.Database.ExtensionMethods-ExecuteScalarInt64]: ExecuteScalarInt64: SELECT "ID" FROM "Remotevolume" WHERE "Name" = "duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes" took 0:00:00:00.000
2020-09-28 21:20:00 -04 - [Information-Duplicati.Library.Main.Controller-StartingOperation]: The operation Backup has started

```

> [@dgcom](#):
>
> have no time to dig in into older code

Not sure what you mean. I showed very latest code. If you don’t like the 2015 commentary, you can ignore.

> [@dgcom](#):
>
> Maybe if there is an effort to move to .Net Core…

You can find a pull request in GitHub that needs lots of help (but not in this area) in order to be ready to go. Major change in discussion so far seems to be replacing the current autoupdater which doesn’t work well.

> [@fred](#):
>
> We could create b2 keys that do not have the **deleteFiles** ability

For maybe less time taken, you could test that on a small test backup with all versions kept and no-auto-compact, to see if it holds up. It will eventually build up a lot of wasted space, but (if B2 allows it, and you don’t mind some vulnerability) maybe you could add that back in for cleanups when waste gets too huge.

---

<div class="post-metadata">

**Author:** ![ts678](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@ts678](https://forum.duplicati.com/u/ts678)\
**Post date:** [November 29, 2020, 1:08pm UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/10 "2020-11-29T13:08:53Z")

</div>

I took a closer look at cleanup. Profiling logs get huge, so I use regular expression filter, in this case

> 2020-09-28 20:20.\*(Backup has started|PreBackupVerify|Backend event: List|Unwanted|duplicati-ie0f0f89a6e164ac3aae8bcc8919e27fb.dindex.zip.aes)

```plaintext
2020-09-28 20:20:00 -04 - [Information-Duplicati.Library.Main.Controller-StartingOperation]: The operation Backup has started
2020-09-28 20:20:28 -04 - [Profiling-Timer.Begin-Duplicati.Library.Main.Operation.BackupHandler-PreBackupVerify]: Starting - PreBackupVerify
2020-09-28 20:20:28 -04 - [Information-Duplicati.Library.Main.BasicResults-BackendEvent]: Backend event: List - Started: ()
2020-09-28 20:20:37 -04 - [Information-Duplicati.Library.Main.BasicResults-BackendEvent]: Backend event: List - Completed: (141 bytes)
2020-09-28 20:20:37 -04 - [Information-Duplicati.Library.Main.Operation.FilelistProcessor-RemoteUnwantedMissingFile]: removing file listed as Deleting: duplicati-ie0f0f89a6e164ac3aae8bcc8919e27fb.dindex.zip.aes
2020-09-28 20:20:37 -04 - [Information-Duplicati.Library.Main.Operation.FilelistProcessor-RemoteUnwantedMissingFile]: removing file listed as Deleting: duplicati-id36ed9475eae44f8a620a893db749b59.dindex.zip.aes
2020-09-28 20:20:37 -04 - [Profiling-Timer.Begin-Duplicati.Library.Main.Database.ExtensionMethods-ExecuteScalarInt64]: Starting - ExecuteScalarInt64: SELECT "ID" FROM "Remotevolume" WHERE "Name" = "duplicati-ie0f0f89a6e164ac3aae8bcc8919e27fb.dindex.zip.aes"
2020-09-28 20:20:37 -04 - [Profiling-Timer.Finished-Duplicati.Library.Main.Database.ExtensionMethods-ExecuteScalarInt64]: ExecuteScalarInt64: SELECT "ID" FROM "Remotevolume" WHERE "Name" = "duplicati-ie0f0f89a6e164ac3aae8bcc8919e27fb.dindex.zip.aes" took 0:00:00:00.000
2020-09-28 20:20:38 -04 - [Profiling-Timer.Finished-Duplicati.Library.Main.Operation.BackupHandler-PreBackupVerify]: PreBackupVerify took 0:00:00:09.735

```

so again, at this look-level it looks like it did a backend List, and did not feel the need for a backend Delete.

If your test actually gets into Delete requests, it will probably be upset that the bucket will fail the requests.  
My test script which replaced the [rclone](https://duplicati.readthedocs.io/en/latest/05-storage-providers/#rclone) program with a script wrapper that randomly fails) found a mess:

```plaintext
Version delete:
2020-08-20 09:50:32 -04 - [Information-Duplicati.Library.Main.BasicResults-BackendEvent]: Backend event: Delete - Failed: duplicati-20200820T131000Z.dlist.zip (1.61 KB)
2020-08-20 09:50:32 -04 - [Information-Duplicati.Library.Main.BackendManager-DeleteFileFailed]: Failed to delete file duplicati-20200820T131000Z.dlist.zip, testing if file exists
2020-08-20 09:50:32 -04 - [Warning-Duplicati.Library.Main.BackendManager-DeleteFileFailure]: Failed to recover from error deleting file duplicati-20200820T131000Z.dlist.zip
System.NullReferenceException: Object reference not set to an instance of an object.
   at Duplicati.Library.Main.BackendManager.ThreadRun()

Compact delete:
2020-08-20 10:30:42 -04 - [Information-Duplicati.Library.Main.BasicResults-BackendEvent]: Backend event: Delete - Failed: duplicati-icd07271238a346309f101338f9d4b083.dindex.zip (44.69 KB)
2020-08-20 10:30:42 -04 - [Information-Duplicati.Library.Main.BackendManager-DeleteFileFailed]: Failed to delete file duplicati-icd07271238a346309f101338f9d4b083.dindex.zip, testing if file exists
2020-08-20 10:30:42 -04 - [Warning-Duplicati.Library.Main.BackendManager-DeleteFileFailure]: Failed to recover from error deleting file duplicati-icd07271238a346309f101338f9d4b083.dindex.zip
System.NullReferenceException: Object reference not set to an instance of an object.
   at Duplicati.Library.Main.BackendManager.ThreadRun()

```

however in theory a test without delete from version retention or automatic compact shouldn’t go there…  
For good understanding of the retry delete handling, someone might have to go looking through the code.

---

<div class="post-metadata">

**Author:** ![Sitwon](https://forum.duplicati.com/user_avatar/forum.duplicati.com/sitwon/32/10198_2.png) [@Sitwon](https://forum.duplicati.com/u/Sitwon)\
**Post date:** [December 3, 2024, 4:39am UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/11 "2024-12-03T04:39:49Z")

</div>

Sorry to revive this thread, it’s the most relevant one I could find.

I’m also interested in using Object Lock or a similar feature for ransomware protection.

Given that it seems Duplicati still does not support B2’s Object Lock, I found this blog post talking about using lifecycle management for Restic.

[https://medium.com/@benjamin.ritter/how-to-do-ransomware-resistant-backups-properly-with-restic-and-backblaze-b2-e649e676b7fa](https://medium.com/@benjamin.ritter/how-to-do-ransomware-resistant-backups-properly-with-restic-and-backblaze-b2-e649e676b7fa)

Duplicati uses a similar content storage strategy, so would this same approach apply?

In short, the suggested strategy is to configure Restic w/ a key that doesn’t have the `deleteFiles` capability, and using Lifecyle Management rules to keep replaced files for the desired period of time before actually deleting old versions.

But it seems that unlike Restic, Duplicati may actually require the `deleteFiles` capability.

---

<div class="post-metadata">

**Author:** ![kenkendk](https://forum.duplicati.com/user_avatar/forum.duplicati.com/kenkendk/32/5305_2.png) [@kenkendk](https://forum.duplicati.com/u/kenkendk)\
**Post date:** [December 3, 2024, 10:12am UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/12 "2024-12-03T10:12:45Z")

</div>

> [@Sitwon](#):
>
> Given that it seems Duplicati still does not support B2’s Object Lock, I found this blog post talking about using lifecycle management for Restic.
> 
> [How to do ransomware resistant backups properly with Restic and Backblaze B2 | by Benjamin Ritter | Medium](https://medium.com/@benjamin.ritter/how-to-do-ransomware-resistant-backups-properly-with-restic-and-backblaze-b2-e649e676b7fa)
> 
> Duplicati uses a similar content storage strategy, so would this same approach apply?

Yes, I think this is a relatively small change that can work with most tools, including Duplicati.

The change to Duplicati is to add an option to the B2 backend, say `--soft-delete`, which would then not request that the files are deleted, but rather request that they are hidden. The list command should ignore hidden files (which I think it does already).

After this change, you can follow the same strategy and issue a key without delete permissions, and set up a life-cycle rule that matches your needs.

I have registered [an issue to get B2 file hiding supported](https://github.com/duplicati/duplicati/issues/5727).

---

<div class="post-metadata">

**Author:** ![fndz](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/f/8baadc/32.png) [@fndz](https://forum.duplicati.com/u/fndz)\
**Post date:** [February 24, 2025, 9:19am UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/13 "2025-02-24T09:19:21Z")

</div>

I’m post this here because i manage to make something “work” with object-lock enable,  
But in fact, i think this is useless because is not supported by duplicati.

We use an S3-compatible storage that provide us Object-lock, how does-it work ?  
When you upload a file, in our case, it’s lock for 2 month, then after 2.5 month, duplicati delete it if it’s no longer needed, that put the file in a sort of trash bin, and finaly, after 3 month, the file are definitly removed from the trash bin by the S3 Storage imself.

So in fact, every new block are locked for 2 month, but the first block that have been here for more thant 2 month but is still needed for the backup are no longer secur.

so if a bad guy want to destroy the backup, i think it can even though there is object-lock on the newest file, by just delete older block. With missing blocks, the backup will be corrupted.

In this case the object-lock is useless i think.  
And i don’t know if they are a real solution to use object-lock for now.

---

<div class="post-metadata">

**Author:** ![ts678](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/t/8491ac/32.png) [@ts678](https://forum.duplicati.com/u/ts678)\
**Post date:** [February 24, 2025, 7:32pm UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/14 "2025-02-24T19:32:20Z")

</div>

> [@fndz](#):
>
> In this case the object-lock is useless i think.

Key words maybe being “In this case”, for the reason stated. Another case might work.

> [@fndz](#):
>
> And i don’t know if they are a real solution to use object-lock for now.

It looks rather cumbersome, but I think at least AWS can extend the lock on the objects.  
Periodically moving locks forward (before they expire) could keep continuous protection.  
[S3 Object Lock retention](https://docs.aws.amazon.com/AmazonS3/latest/userguide/batch-ops-retention-date.html) describes. One would also requires some cold storage options.  
This includes no compact and no version deletes, unless maintenance can be arranged.

There’s also a temporary issue after upload failures, as remnants might require deletion.  
Basically though, if you can lock known-good backups and extend locks, that might work.  
I don’t use locks yet, but they sound hard to work with, especially given Duplicati’s usage.

[Locking objects with Object Lock](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-lock.html) describes softer file lockings such as governance mode. Compliance mode is very rigid compared to having an administrative path to solve issues.  
Don’t give Duplicati authority for that, but having some escape hatch makes me feel safer.

---

<div class="post-metadata">

**Author:** ![kenkendk](https://forum.duplicati.com/user_avatar/forum.duplicati.com/kenkendk/32/5305_2.png) [@kenkendk](https://forum.duplicati.com/u/kenkendk)\
**Post date:** [February 27, 2025, 8:29pm UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/15 "2025-02-27T20:29:55Z")

</div>

> [@fndz](#):
>
> We use an S3-compatible storage that provide us Object-lock,

Does your S3-compatible storage provide versioning? If so, that should be compatible with Duplicati, as it only views current objects, not object versions. A delete operation will then create a “deleted version”, and at least on AWS S3 you can use lifecycle rules to remove objects later.

If Duplicati does not have permissions to access/modify versions, an attacker will not be able to either.

> [@fndz](#):
>
> But in fact, i think this is useless because is not supported by duplicati.

I don’t think it works well with Duplicati, because of the way data may change.  
When doing a compaction, the resulting `dblock`’s will contain a mix of blocks with different ages.  
At this point it is possible that a newly created `dblock` actually contains very old data, and the next version removal will target the new `dblock` for delete/replace.

If the object is locked, it will fail then.

> [@fndz](#):
>
> it’s no longer needed, that put the file in a sort of trash bin,

This is another way to deal with lack of delete/modify permissions. If the destination supports a rename function, it would be possible to move/rename the file into a `/trash` subfolder, from where it could then later be deleted.

This logic has not made it into the core project yet, but we do have it in the new remote-synchronization tool. To use it you would need some kind of hot-storage (maybe local) and then run the remote-synchronization tool to synchronize hot-storage with cold-storage, and here you can choose to use `--retention` to rename instead of deleting.

---

<div class="post-metadata">

**Author:** ![fndz](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/f/8baadc/32.png) [@fndz](https://forum.duplicati.com/u/fndz)\
**Post date:** [March 4, 2025, 4:26pm UTC](https://forum.duplicati.com/t/immutability-feature-for-randsomware-protection-s3-b2-object-lock-or-application-keys-without-deletefiles-permission/11136/16 "2025-03-04T16:26:08Z")

</div>

> [@kenkendk](#):
>
> Does your S3-compatible storage provide versioning? If so, that should be compatible with Duplicati, as it only views current objects, not object versions. A delete operation will then create a “deleted version”, and at least on AWS S3 you can use lifecycle rules to remove objects later.

Thats what i mean when i says “trash bin”, when a object is deleted by duplicati is transform in a “deleted version” and this version is remove later by the system.

> [@kenkendk](#):
>
> When doing a compaction, the resulting `dblock`’s will contain a mix of blocks with different ages.  
> At this point it is possible that a newly created `dblock` actually contains very old data, and the next version removal will target the new `dblock` for delete/replace.

Thats really intresting, in my backup job, i don’t have remove the compaction work. So thats possible some newly blocks contains older data.

In my case, with my S3-compatible storage, i have some the oldest dblocks that no longer locked, the main problem is if an old block is delete, even if the versionning is enable, the lifecycle immediatly remove them because it’s older than what i defined in the lifecycle rules.

one sollution is to not delete “deleted version” but the storage gonna be bigger and bigger and the cost of the storage gonna be realy big.
