[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How do I recover my file I deleted from the command-line with mv?

Posted on 2005-04-19
9
Medium Priority
?
346 Views
Last Modified: 2010-04-20
I was working on a script via the vim editor through putty on my Windows machine when my system crashed. When my windows machine booted back up I re-connected through putty and killed the vim process. I just saved a couple minutes before my windows system crashed, so it wouldn't have been a big deal if I just went back to my script, but without thinking I went ahead and did something stupid. I overwritted my script with the .swp file, which turned out to be corrupted.

# mv .my_script.swp my_script
mv: overwrite `download'? y

90% of my script is now garbage. Is there anything I can do. I do have a backup, but that's from a couple days ago. If I don't get that back the last 4 hours will have been a waist. What can I do? Is there anyway to undo the mv command.

Please help!!!
0
Comment
Question by:itcdr
  • 5
  • 3
9 Comments
 
LVL 38

Expert Comment

by:wesly_chen
ID: 13821260
1.
mv  my_script  /other-filesystem/my_script.bak

2. umount the filesystem first. If it is the NFS mount filesystem, then the file is probably unrecoverable.

3. Then download "e2undel"
http://e2undel.sourceforge.net/

Good luck.
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 13821262
Read the howto of e2undel first
http://e2undel.sourceforge.net/recovery-howto.html
0
 
LVL 1

Author Comment

by:itcdr
ID: 13821279
It is NFS mount filesystem. Any other ideas?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 38

Expert Comment

by:wesly_chen
ID: 13821317
Login to NFS server and start from step 1 to step 3.
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 13821327
If the NFS server is NetApps or some sort of commerical file server,
then it may have ssetup napshot which keeps the data half day ago. So you can copy back from snapshot directory/area.
0
 
LVL 1

Author Comment

by:itcdr
ID: 13821338
OS: Linux Fedora Core 3
CPU class: x86
CPU: Intel P4
HD: SATA

It doesn't have NetApps. I'll try the steps you said, but you also said, "If it is the NFS mount filesystem, then the file is probably unrecoverable." that's why I asked if you had any other ideas.
0
 
LVL 38

Expert Comment

by:wesly_chen
ID: 13821398
Because NFS server is read/write by other users at the same time.
So it is very possible that the original inode and disk block to be overwritten by other files.
0
 
LVL 7

Accepted Solution

by:
macker- earned 1500 total points
ID: 13829851
As wesley has indicated, it's all a matter of "luck".  When mv or rm is used, the data itself isn't deleted, it's just a matter of saying "the data for this filename is at this address on the disk", and simultaneously marking that address (inode) on disk as being unused.

In a single user environment, there's a reasonable chance that nobody else has yet made changes that might have written data to that file location.  On an NFS server, there's typically multiple users, so those odds become much worse.  Since the file is recent, it's more likely that it was in an area of the disk that's going to be re-used soon, unless a file located closer to the start of the disk is deleted before someone writes a file that allocates the unused space where your file was.

Also, with regards to "undelete" software, be careful... it could cause filesystem corruption.  You'll also need administrative (root) access to the server where the physical drive is located.

In general, I'd suggest saving your time and looking at cvs and/or backups for future and spend your time now on rewriting the script, rather than trying to undelete the file.
0
 
LVL 1

Author Comment

by:itcdr
ID: 13829937
Thanks. I did go ahead and rewrite the script.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month19 days, 12 hours left to enroll

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question