As
@Condobloke mentioned in post #2, it's best if nothing is run that involves the 5TB drive if you want to rescue as much as possible from it. Any more activity on the disk will only alter the filesystem which will likely disturb it more than it already is.
One common approach is to use the testdisk program and the photorec program, both of which are outlined here:
https://www.cgsecurity.org/wiki/TestDisk. There's a learning curve to using them but the documentation is quite extensive.
When recovering files, it's really necessary for best results to leave the problematical external drive unmounted, and use the recovery tools, testdisk and photorec, from either a live disk or the installed operating system if it's functioning properly. You will need a location to copy recovered files to which could be a usb, a connected computer, a directory on a properly functioning installed system, another external hard disk etc. If the installed system doesn't boot, use a live disk or rescue disk.
It's not clear why the system would spontaneously reboot if you were working in the
/var directory. Uninitiated rebooting is often associated with faulty memory, so one might consider testing the RAM with the memtest86+ program.
Check the logs to see if there's any information that might be helpful. One or more of the commands like the following can help:
Code:
journalctl -b
journalctl -b -x -p 3
journalctl -b | grep -i error
dmesg
Other than faulty RAM, there are other possibilities that can cause uninitiated reboots like an overheated CPU, power supply fluctuations or motherboard issues which can get a bit technical, but the RAM check would be the first check I'd make.