KenKundert / emborg

Interactive command line interface to Borg Backup
GNU General Public License v3.0
94 stars 8 forks source link

Improvements on the diff command #47

Closed stratosgear closed 2 years ago

stratosgear commented 2 years ago

Before actually reading the docs for the diff command, I was thinking/hoping that it would do a diff of the contents of the current dir against the latest backup, but alas it does not... :(

My use case, is that I want to easily see if the contents of the current dir have been changed since my last backup. I never thought that I will need the diffs between two arbitrary previous backups (although useful for some cases, I guess).

My suggestion would be that if you pass NO arguments to diff then you compare the last backup with the current folder (and subfolders, I would guess)

If you pass a single parameter (of any previous backup) you can diff that backup with the current folder.

Passing two params is what you currently have.

As a workaround, for now I mount the latest backup in a random folder and I manually diff the folders (having to laboriously copy the full path to the folders I need to compare). Doable, but I believe (as I originally thought) this functionality should be native to emborg.

BTW, while I was doing the above mounting exercise I came across [another issue (#48) (I believe)...

stratosgear commented 2 years ago

It is worth noting, that the usefulness of this command will greatly depend on the automagic way of comparing folders, without actually having to type any folder paths (as long as you run it from inside the folder you are interested in).

Similar to the way I can visit a folder and do a restore by simply supplying a filename only!

KenKundert commented 2 years ago

That is an excellent idea. Let me see what I can do.

KenKundert commented 2 years ago

In looking into this more, I am beginning to think I should leave the existing diff command alone, or perhaps add a path argument to limit the diff to a particular file or directory like with the manifest command. The reason is that Emborg's diff command is a thin interface over Borg's diff command, and enhancing it like you suggest would take a lot of extra machinery and complexity.

Instead, I am think of adding a new command, perhaps named compare, that would do just what you did. It would mount an archive, it would then run an external diff command and when complete, it would unmount the archive. The external diff command would be preconfigured using an Emborg setting, and could either simply list the differences (diff -r) or it could open a interactive graphical interface that would allow you to examine and perhaps copy over differences (vim dirdiff or meld).

Would that satisfy your needs?

KenKundert commented 2 years ago

I have added the compare command command and updated the Emborg GitHub repository. To use it you will need to add the following settings: manage_diffs_cmd, report_diffs_cmd, and default_mount_point. I hope you like it.

stratosgear commented 2 years ago

You're the best! :)

When are you planning a newer release? It looks like it is custom made to my needs! Thanks!!!

KenKundert commented 2 years ago

Thank you. Yeah, I really like it to. I think I am going to get a lot of use out of it.

I'm still writing more tests and cleaning things up. It will probably be available in pypi by the end of the week.

KenKundert commented 2 years ago

The release that fixes this issue (1.25) has been pushed to pypi.