No, it’s not targeted at lock files only. However, the reason for this rule are mainly the lock files. (And yes, it should be possible to limit the rule to lock files only)
Currently, when I run a forget
/prune
on my trusted machine, the files won’t be deleted immediately. Instead, a delete marker would be created and the files will be deleted 30 days later. So I also have a last resort “undelete” possibility, if I make a mistake.
You are right, if there are multiple versions, this is an indication of someone trying to tamper. But… Interestingly, I now had 2 cases where I had 2 versions of the same object and it was not some evil attacker. (I am running this setup for 2-3 years now, and have >10 repositories with about 2 TiB of data.)
Both times, the two versions where binary identical. My guess is that the following happened:
- restic uploads the object data
- the final “ACK” from the S3 server goes missing - maybe because of a longer interruption of the internet connection
- restic is still running and retrying the upload from start
- a second object with the same name and same content is stored
I don’t know if the S3 server would also store the data, if the upload was interrupted in-between (I hope not). If yes, then it could even happen that there a 2 different versions of the same object. However, those object should both be pretty new.
If you get 2 versions of an object and one of them is older than your last check of the repo, then it really looks like you are in trouble. (Either because of an attacker or because of unreliable S3 storage)
This is the lifecycle rule I use:
{
'Rules': [
{
'Expiration': {
'ExpiredObjectDeleteMarker': true
},
'ID': 'delete-after-30days',
'Filter': {},
'Status': 'Enabled',
'NoncurrentVersionExpiration': {
'NoncurrentDays': 30
},
},
]
}