Removing old backups by file differency

Hello…
How to keep last n versions of file diff?

Here is example:
-File is created
*backup run repo1.
-file is updated
*backup run repo2.
-file is updated
*backup run repo3.
*backup run repo4.
*backup run repo5.
*backup run repo6 .
*backup run repo7.
-file is updated
*backup run repo8.

So how to delete old backups of file to keep last 2 versions (repo8 and repo3)?
I think that --keep-last 2 will keep file in repo8 and repo7 so I lost that version in repo3.

1 Like

Restic doesn’t working across multiple repositories the way you describe it, e.g. when forgetting snapshots. And forgetting is about snapshots, not about specific files.

What problem are you trying to solve by wanting to do this?

Imagine that program is written. (backup)
Then some feature in program is added. (backup)
now some months later and a lot of backups we found that feature added wreck some other part and want to see diffs of last version and version before. But in meantime older backups are deleted.
So if keep last few versions of file will prevent lost of previous file.

You want a version control system, not backups. Git is a popular VCS, as is Subversion. You should use one of those instead.

A proper VCS will support complex development workflows, including branching and merging. Restic will not do any of this. Restic is the wrong tool for this job.

1 Like

@eslavko Exactly what @cdhowie wrote, what you should do is use a version control system like Git to record changes in your source code for the program. Then as you back that versioning up (e.g. the .git folder in your program’s source code project), you will always be able to restore the previous versions of that source code inside your VCS/Git.

Until now I used rdiff-backup. It has simple command to list all difference for chosen file and deletion. But doesn’t have deduplication and take a lot of space. And it’s written in python2 now near obsolete. There are new version written in python3 but isn’t compatible. So it’s time to switch for something working better.

Yeah. What you should be using (if you ask me) is: Git for versioning your source code (this will allow you to go back in time) and restic to back all of this up (this will allow you to restore your source code and it’s history in case you lose the original data).

AFAIK the git is not best with binary codes. And I have a lot of SD card images and need to backup versions. And I have a lot of small projects and git seems to be overcomplicated as only thiny part of them is needed.

So is it not software source code? You said this:

Usually you aren’t doing software development with binary blobs. You have some source code of some kind. You typically don’t put compiled output in version control, nor do you usually need to back it up because you can just recompile the corresponding source code.

Well I write that as example. In reality it’s source and binary files. (binary as data not compiled sources)

Maybe something like git-annex is what you want for the binary data. Regardless, restic is the wrong tool for tracking code versions.