I wanted to make a copy of a DCIM folder, copying it from my Kaylee, my desktop machine to Inara, my HTPC. While it’s not the fastest approach, SSH is reasonably quick, unattended, especially if you tune a few parameters in sshd_config, such as prioritizing block ciphers, and in ~/.ssh/config, such as disabling compression when you know the data’s going to be moving across a local gigabit network.
Now, I rather like Midnight Commander. If you grew up on DOS appreciating Norton Commander, you’d probably like it, too. Midnight Commander supports file transfer and browsing over SSH, complete with progress meters and the like. That makes it a generally handy tool for this kind of thing.
So I ssh’d to my desktop box from a screen session on my HTPC, launched mc, and told it to connect to Kaylee. Then I selected a relatively small folder, DCIM. This particular DCIM directory was only two gigabytes or so. This was after an earlier aborted attempt to copy some files over; I had to run a quick errand. So when it prompted me whether or not I wanted to overwrite, I told it, All.
I wasn’t happy with my transfer rate, so I aborted, deleted my target directory, and went to try again.
Did you see what I did wrong there?
I connected to Kaylee, launched mc, told mc to connect to Kaylee, and then told it to copy a folder to itself, via SSH link. So I was, file by file, overwriting every file in that DCIM folder. And then I aborted halfway through a transfer. And then I compounded the error by deleting the file. So I deleted 2GB of photos.
A quick search on DuckDuckGo for ext4 undelete turned up extundelete, which turns out to be exactly the tool I needed. One minor rub: the tool requires the filesystem to be unmounted.
So, after killing all the processes using files on the filesystem my home directories happen to sit on, I ran
mount -t ext4 -o remount,ro /dev/device-node /path/to/mount/point
to remount the filesystem read-only. Then I ran the tool. It worked flawlessly, and I got my photos back.