mtkennerly / ludusavi

Backup tool for PC game saves
MIT License
2.55k stars 58 forks source link

Add option to translate Wine prefixes across OSes #194

Open mtkennerly opened 1 year ago

mtkennerly commented 1 year ago

What's your idea?

This was proposed in https://github.com/mtkennerly/ludusavi/issues/156#issuecomment-1496330814.

mapping.yaml could contain some additional fields on each backup:

Use cases:

This would also allow us to show a badge on non-native backups or add an option to prevent restoration unless they can be translated/redirected.

danepowell commented 8 months ago

Would this also solve the use case of syncing Wine games Linux to Linux, where each machine has a different user name? Currently you can set a redirect for /home/user on each machine, but the problem is the username is also encoded in the path drive_c/users/user in the wine prefix. Unless you create a separate redirect for every game, I don't see how to fix that.

mtkennerly commented 8 months ago

Ah, that's an interesting case. I think that would need a different solution, since it's a path inside of the Wine prefix rather than the prefix as a whole.

One option would be to add some kind of Wine-specific redirect support or even more specifically just to handle usernames. A more general, but slower/advanced solution could be to add support for redirects using regular expressions with capture groups. Then you might have something like:

danepowell commented 8 months ago

I agree the regex solution seems best. Shall I open a new ticket for that?

mtkennerly commented 8 months ago

Sure, that would be great :)

Mike3137 commented 7 months ago

I'm sure you have thought about it and there is a good reason why you don't do it this way. But why aren't the backups made with a relative path instead of absolute path of the source machine.

Like if the save path is $XDG_CONFIG_HOME/game/save.sav the backup folders could be something like /backupfolder/gametitle/xdg_config_home/game/save.sav instead of /backupfolder/gametitle/drive-0/home/username/.config/game/save.sav.

This way it would be possible to restore on a different computer, right now I always have to manually edit the backup folders and yaml to match the target machine's paths before restoring.

I guess you would have to select where to restore each relative path, especially for wine prefixes. But for most other cases the default should be fine.

mtkennerly commented 7 months ago

@Mike3137 There are some complications with that approach:

By using absolute paths for everything, Ludusavi can ensure that a save backed up from one location will always restore to the same location on the same system.

That said, you could use the redirect feature to do something like you described. For example, you could define this on each of your systems (just changing the username):

image

right now I always have to manually edit the backup folders and yaml to match the target machine's paths before restoring.

You can use the redirect feature to make this a lot easier. If the main issue is the username, then this might be all you need:

image
JoshElias commented 4 months ago

@mtkennerly This might not be the best place to ask this question but does Ludusavi currently support Windows <-> Linux backup and restoration?

I just tried doing a backup on my Windows machine and restoring on my Linux and they all failed due to the path names being too long.

mtkennerly commented 4 months ago

@JoshElias It does support it, but you have to set up redirects (on the "other" screen), so it's a bit limited. It's not automatic because it's hard to say exactly where a Linux path should restore on Windows and vice versa.

A simple (but not exactly correct) example: on Linux, you could set up a restore redirect from C:\ to /windows/c, and on Windows, you could set up a restore redirect from / to C:\.

To be more correct, you'd probably want to set up specific redirects like /home -> C:\Users. However, even then, there might be a game that uses fundamentally different save paths on different OSes. For example, according to PCGamingWiki, Celeste uses <path-to-game>\Saves on Windows, but $XDG_DATA_HOME/Celeste/Saves on Linux.

Nicoxys commented 4 months ago

@mtkennerly Have you any plan to add some magic into ludusavi to support this automatically? Or it's hard to the point it cannot be done? Even if only for syncing non-steam windows game (proton) in steamOS and windows games on windows system.

I mean, if ludusavi can recognize my non-steam games based on their name matching pcgamingwiki info (and it seems to do so), probably it can sort things out in some way.

Thank you for your effort

mtkennerly commented 4 months ago

@Nicoxys I do still want to try to support it, but since it is quite a difficult feature, I don't have a specific timeline in mind.

happyme531 commented 2 months ago

I am also wondering why Ludusavi use full/absolute path for storing backup, which seems unnesserary and is causing trouble now.

By using absolute paths for everything, Ludusavi can ensure that a save backed up from one location will always restore to the same location on the same system.

It seems better to store the savefile content in relative manner, and store the necessary perfix information per-system in the metadata file.