Confused about the restore process

I’ve gone through the reference page for restoring a file, and it seems to require knowing the snapshot string.
What if I don’t have the string?
I just have the filename ("$env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt") and want the most recent version on the new machine.

Previously I used Robocopy for backups, and I would copy "$env:APPDATA\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt" to "$O:\conf\ConsoleHost_history.txt", and I would just flip the two on restore.

I have a bunch of these source-target pairs, and the restoration process is a part of a Windows setup script.

run : kopia snapshot list -l and extract last line, where 4th field is snapshot ID that you can use on restore

Another way is to mount backup and access file you need from mounted path

For kopia snapshot list -l is there any difference between passing O:\projects and al@desktop-1ntevv8:O:\projects as the last argument?
Output looks the same.

I assume when I start doing backups on a new machine/install, the al@desktop-1ntevv8 bit will change. In that case, will passing O:\projects show the snapshots for the folder from both machines/installs?
Then I will no longer be able to rely on simply grabbing the last line, will I?
Because the new machine might be listed above the old one.

Actually I’ve ended up trying it on a new machine, and the command straight up doesn’t list anything.
Seems like kopia snapshot list --all is the one I want.
The question regarding host/username still remains though.

Update: And when on the new machine I can’t even run kopia snapshot list --all O:\projects because that outputs nothing.
It appears I have to run kopia snapshot list --all al@desktop-1ntevv8:O:\projects instead, which means we’re back to square one: I don’t know the “al@desktop-1ntevv8:” bit (or rather the script doesn’t).

Unless I’m missing something. it seems like kopia’s “workflow” disallows automation.
Is there a way to get rid of these random strings?
I just want the latest snapshot of every file and folder throughout all backups from all hosts.

Do you run kopia in server mode and pushing backup from different computers to it ?

those random strings are unique identificators of every snapshot, so - no, it can’t be removed.

If you running centralized kopia server that consolidating backups from all computers, then you have to use --all option in snapshot list command and you will get list of all shapshots separated for each host by

prefix: username@host:/path/of/snapshot/on/source/computer

followed by all snapshots for particular host/path. You can use also option --reverse for change sorting order as well limit maximum number of entries with --max-results or get in easy parseble output with --json option and pipe it to jq or dasel or powershels’s ConvertFrom-Json that has very powerful mechanisms to filter JSON content.

kopia produce more than enough information to automate it. It just followed all wisdom - “do one thing, but do it best”. It can’t fit to everybody’s wishes and satisfy all possible combinations how users will bend it. In your particular case, if I got it right, you just need to do post processing to filter out data you need.

Nobody except you can knew this. This is identification bit of remote computer in form user@host. You have to go through all computers, run sysdm.cpl and write it down computer’s name (hostname) as well you have to figure out the username who is running kopia on that particular host, then you will get missed “bit”

I’m not using server mode.
I never need to access the backup from more than one computer at a time.

I was referring to the al@desktop-1ntevv8: bit which is stopping me from using the backup created on one machine/install on another machine/install without manually plugging in that hostname.

It’s not about me knowing it.
It’s about the script knowing it.
If I back up a directory a few times on computer A, then I need to run sysdm.cpl or whatever and paste that in the script to restore the latest snapshot of the directory on computer B.
Then after I back it up a few times on computer B and plug the drive into computer C, I once again have to edit the script, deleting computer A’s hostname and now replacing it with with computer B’s hostname.
Etc. etc.
That is not very automated.

I don’t think the “do one thing, but do it best” logic applies here.
That principle is about making a piece of software as simple as possible, only accomplishing a single task (e.g. cat).
Kopia in general seems to take the opposite approach and has more features built in oob than the competing products.

It really hard to understand your backup workflow… Are you using a single external hard drive and moving it around other computers and backup to the same repository located on that external drive?

More or less, yes.
I back up and restore the same set of files and folders across multiple VMs, clean Windows installs (for when Windows breaks) and occasionally to another physical machine (and in the near future, a new physical machine).

I think you have to use kopia in server mode for such cases