Synching game saves by size

I use Synchthing to sync game saves from Retroarch. As far as I know, the only way to track changes for saves would be to check if the save file size has increased. So is there a way to sync only if the file size has increased (or remained the same) on either computer and not solely based on time of modification?

Syncthing will index the file (looking for changed blocks) if any of the size, modification time or permissions have changed. I don’t really know if that answers your question; if it doesn’t, perhaps you can clarify the question. :slight_smile:

For example if I played a game on Retroarch. Whenever I save in-game, Retroarch writes a .srm file that contains the saved data of the game. And the .srm increases over time as more progress has been made in the game.

Lets say that I made 5% progress in a game on device ‘A’ and then save, but I wasn’t connected to the internet at the time. Then if I open the game on device ‘B’ (with 0% progress) then close it. Now if I run Syncthing the save file from device ‘B’ (with 0% progress) will overwrite the save file on device ‘A’.

I have versioning set to keep backups. But I’d rather have Synchthing (in my use case) configured to not overwrite larger files with smaller files.

There’s no such setting, but what you describe should not result in an overwrite but a conflict, with both variants saved. Generally speaking, when you have a two way sync of something, you’re better off only changing it on one side at a time.

Okay, thanks for the info!

Just an idea, but I think this could possibly be achieved with some not-so-advanced hackery based on external versioning. Basically, you enable external versioning setting Syncthing to run a script that would remove (or rather move somewhere else) the file. At the same time, make the first script open a second script that would then wait for Syncthing to replace the file, check the new size, and then restore the older file back if needed.

Edit: I forgot to add that for the above the work, conflicts probably need to be disabled in the Advanced Configuration.

That could work. But one of the devices that I use is Android. And from reading the docs I can’t determine how to write a script for Android. The other is GNU/Linux (Fedora), so I can basically compare file size like so:

function getFileSize {
	echo $(wc -c "$1" | cut -d ' ' -f1)

if [ $(getFileSize "$1") -ge $(getFileSize "$2") ]
	then echo same size or larger
	else echo smaller size

I might try writing a script next weekend implementing your idea. But that might fail due to:

second script that would then wait for Syncthing

race conditions.

Android should be able to run .sh scripts as long there is the actual sh binary in the system path. If there’s none, then I’d guess you could probably copy your own sh from BusyBox or something to /data/local/tmp, add the executable permission with chmod +x /data/local/tmp/sh, and then use that to execute the script with /data/local/tmp/sh <path-to-script>.sh. You may need to use ADB to copy the file and change the permissions first.

If you’re rooted though, then you can probably just install BusyBox and call it a day. Custom ROMs also often come with basic tools built in.

However, the script itself may better not rely on GNU tools like cut and similar. I think as long as you use native bash commands, you should be fine though.

That sounds a bit too extreme. Considering that I have a Samsung S8+, which is fairly locked down system wise. I might resort to using rclone (on Termux) and the solutions from these two projects then: arklone and preservatives

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.