Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Dearest Monks,
I hope someone here can help me recover a currently running script from memory.
Sometime yesterday one of my primary drives failed, on that drive was about 160 gigs of data. One of the most important things in the 160 gigs was a perl script that is run on other machines in my network via SMB. Now, I have located a single running copy of the script on one of the machines. The primary drive is on a linux system and uses ext2 with journaling. In the past I read an article detailing how to recover files from memory, but for the life of me I cannot find it now. The closest I have found is at

http://www.itworld.com/nl/lnx_sec/05072002/

The only thing I have been able to recover using those instructions is the perl binary itself. If anyone can offer a helping hand I sure would appreciate it, I have no idea how much longer the script will run before failing an attempting to restart.

Thank you !

20041015 Edit by ysth: add p tags, bracket link, retitle from Perl Script Recovers from memory

  • Comment on Recover a running perl script from memory?

Replies are listed 'Best First'.
Re: Recover a running perl script from memory?
by tachyon (Chancellor) on Oct 15, 2004 at 00:36 UTC

    You can dump memory on Linux just by doing:

    cat /proc/kcore > dump

    That will put a raw dump of everything in memory into the file dump.

    However you will not be able to recover plain ASCII text of your script from such a dump because it is simply not kept in memory. Nor is a file decriptor help open for it (as in the lsof example you quote). A file descriptor would just let you access the disk so is fairly pointless in this case anyway.

    I would suggest data recovery on your disk. Spinrite may do the trick if your crashed disk will still spin up.

    cheers

    tachyon

Re: Recover a running perl script from memory?
by belg4mit (Prior) on Oct 14, 2004 at 19:23 UTC
    Have you tried the other other file descriptors (entires in fd) for that process? The only other thing I can think of is if you have root access trying to find something in RAM, but then it's going to be the compiled op tree and not the source.

    --
    I'm not belgian but I play one on TV.

Re: Recover a running perl script from memory?
by jfroebe (Parson) on Oct 14, 2004 at 20:37 UTC

    Hi,

    Pulling programs from memory would essentially forcing a memory dump of the program's executing process plus any shared memory that would be attached. Another method is scanning the filesystem cache to pull as much data as possible... It is a hit and miss situation.

    btw, ext2 + journaling ~= ext3.

    Jason L. Froebe

    No one has seen what you have seen, and until that happens, we're all going to think that you're nuts. - Jack O'Neil, Stargate SG-1

Re: Recover a running perl script from memory?
by TedPride (Priest) on Oct 14, 2004 at 21:44 UTC
    Depending on how your drive died, most or all of the data can probably be recovered using external hardware. My advice is to take the hard drive to a recovery specialist.
Re: Recover a running perl script from memory?
by DrHyde (Prior) on Oct 15, 2004 at 09:03 UTC
    Why not just restore from your backups?