You just want the files restored for the users, no sharing no app data? And the clients will resync all the files again from nothing…? I’d do a fresh setup, create all the users, then copy the files for each user back and run the occ files:scan
. I wouldn’t bother with the config.php, there is just a risk that you copy some old stuff that creates problems later.
If the php versions allow it, then you can migrate your complete Nextcloud setup on the machine with the new operating system. No resync needed, everything as it should be. E.g. on Debian 11, you update until NC 25 (lastest possible with php7.4), then you migrate to Debian 12 and directly run your upgrade to NC 26 which supports php 8.2. Or on Debian 11, you install some php 8.x version to go up to NC 26.