Long story short...

I wrote a CLI events calendar for Linux in C++ (one of my first major C++ programs), and it came to around 2400 lines of code. I've been working on it for a few weeks now getting things just right.

I just finished getting a decent working copy of the program and copied the executable to my /usr/local/bin directory (linux) so I could play with it some.

I, then, decided it'd be a good idea to set up a local CVS repository so I can do some version tracking, since NetBeans supports this. In the process, I set my home directory to the cvs repository directory and entered "cvs init"

My home directory got wiped and, frankly, I didn't mind losing anything else except for this program I had been working on for a while.

How would I go about retrieving this? I imagine it's considered a deleted file...?

Is there a way to reverse engineer the code? The program functions as it is, but I don't feel it's really "complete" yet, so I want the ability to continue editing it from where it is until I feel it's more or less finished.

I'll chalk this one up to not backing it up...I know I should have, especially more often. But this very rarely happens to me and the thought didn't even cross my mind.

If it's really not too retrievable, I guess I'll leave it as-is (functional, but missing some features imo), and move onto a new programming project.

Thanks in advance
-Josh

Dani AI

Generated

Immediate, short plan for (do this first)

Stop using the affected partition right away — every write lowers the chance of undeleting files. If possible, boot from a live USB and either unmount the partition or remount it read-only before doing anything else. (extundelete.sourceforge.net)

Safe, practical workflow (work from an image)

  1. Boot a rescue/live system and identify the device (lsblk or fdisk -l).
  2. If the partition is mounted, unmount it (sudo umount /dev/sdXN) or remount read-only (sudo mount -o remount,ro /dev/sdXN /mount/point).
  3. Make a full image and work from that (don’t write to the original):
    sudo dd if=/dev/sdXN of=/path/on/external/disk/image.img bs=4M conv=noerror,sync status=progress
    sudo losetup -f --show /path/on/external/disk/image.img   # attach loop device
    sudo extundelete /dev/loopX --restore-directory home/youruser

    Always restore recovered files to a different drive than the one you’re imaging. (extundelete.sourceforge.net)

If extundelete doesn’t find your files

Try filesystem-aware tools first (extundelete, ext3grep, ext4magic for ext3/4), then file-carving tools if needed (TestDisk / PhotoRec, foremost, scalpel). PhotoRec/TestDisk are especially useful when inode/journal metadata is gone and you need signature-based recovery. (extundelete.sourceforge.net)

If all you have is the executable

Copy the binary off immediately and use strings and objdump to extract readable literals and a disassembly, then try a decompiler like Ghidra to reconstruct program logic — this will not recover original C++ sources, comments or local names, but it can speed reimplementation. Example commands:

strings ./myprog > /tmp/myprog.strings
objdump -d ./myprog > /tmp/myprog.disasm

For reversing/decompilation, Ghidra is a strong free option. (en.wikipedia.org)

On contacting the CVS list (as suggested)

If you ask the CVS folks, include: exact commands you ran, the device name, current mount state, filesystem type, and whether you already imaged the disk. Clear details help them advise whether repository-specific metadata might be recoverable. (extundelete.sourceforge.net)

Cautions: do not run recovery tools writing to the affected partition; image first; expect that full source (with comments) usually cannot be reconstructed from a stripped binary.

Recommended Answers

All 2 Replies

if it were me, i'd probably get on the CVS help mailing list and ask the experts if there's a way to restore.

for the best chance of getting help from them, you'll want to clearly and concisely describe what exactly you had, what you did, and what you have now.

if it were me, i'd probably get on the CVS help mailing list and ask the experts if there's a way to restore.

for the best chance of getting help from them, you'll want to clearly and concisely describe what exactly you had, what you did, and what you have now.

Thanks, I may end up doing that. Right now, I'm somewhat accepting the program may be a loss though.

I'll try that though and see if it ends up with any success :)

Thanks for the suggestion!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.