Rolling back a file

16,080

Solution 1

I'm sorry to say that if you didn't make any backups, you're almost certainly SOL here, especially from the command line.

Unlinking (deleting) a file can sometimes leave the data recoverable as long as nothing else grabs that particular inode; editing a file overwrites the data.

If your colleague still has the editor he was working in open and its undo buffer is long enough, that might be a way to recover the original, but beyond that I'm afraid you're sunk. Sorry.

Solution 2

Assuming you're using ext3, it might be possible to recover it if the replacement file was created as another inode (instead of overwriting the existing file), by using debugfs on the unmounted filesystem, and to find the inode of the original file. Unfortunately, if your colleage overwrite the file, rather than moving it aside and then deleting it, it's gone. I would suggest using debugfs with extreme caution, because you can seriously mess up a filesystem. It's use is only really for a last-ditch effort.

Share:
16,080

Related videos on Youtube

Elitmiar
Author by

Elitmiar

Updated on September 17, 2022

Comments

  • Elitmiar
    Elitmiar over 1 year

    I have a situation, a colleage of mine overwrote PHP files that I've made changes to , is it possible to roll back a file to a previous working version using the command line. No svn repositories are available and also not any backups.

  • Elitmiar
    Elitmiar about 13 years
    Thanx for the response, busy setting up a SVN repository, just thought maybe maybe there's a chance of getting it back
  • Elitmiar
    Elitmiar about 13 years
    @thanks, no unfortunately it wasn't created as a inode, thanks for the response.
  • Blender
    Blender about 13 years
    I usually just tarball my work and delete that tarball every once in a while. But I'd seriously consider git, hg, of svn to backup your code. You can even schedule it to commit every few hours with cron if you have to.
  • maaartinus
    maaartinus about 13 years
    @Roland Consider using git, after some learning it's so easy to use and so fast, so you'll never think about not versioning anything (and you'll not understand how you ever could use svn). I need less than one minute to create a repo for a new project, to commit, and to clone to a server. Just my opinion, not gonna start a flame war.