Recovering deleted files, if possible.

mohit tomar

New Member
Credits
0
Hello,

I was working with some obsolete xls/xlsx files and at the same time learning to work with commands. As I'm a beginner with linux. However what I discovered is that mv command should be used with utmost care as what seemed to me is that it is as dangerous as rm command.

So following is the command that I ran and the result it had.

"find . -type f -name '*.xls*' | xargs -I '{}' mv {} xls_files_destination"

However there isn't anything wrong with this command but what mistake I made was that I mistyped the destination directory name which was actually xls-files-destination. And this resulted in find command locating all the xls and xlsx files on the current directory "." and then moved all those files to a new file called xls_files_destination.

At the beginning of this exercise I had a total 2243 xls files as i used "| wc -l" pipe to check for the total files. The find command took 2-3 seconds and turned all the xls files into nothing.

Now there is no xls files in my folder and the size of new xls-files-destination file is also just 91b.. ;-) :) hehehe..

I was wondering how fast I would have lost my job if this was done on an actual production system.

Anyways all the xls files were just useless old data.

What I'm looking for is if there is a way if such an accident happen in real then how to recover the files.

Thanks in advance :)
 


wizardfromoz

Super Moderator
Staff member
Gold Supporter
Credits
7,500
Geez, you did a good job, but perfectly understandable ;)

G'day @mohit tomar and welcome to linux.org :)

(Wizard appears in a puff of smoke)

You haven't said what Linux Distro you are using, you could let us know.

I'll run a few ideas past you.

Many of the Linux Distros feature in their Repositories (repos) Christophe Grenier's TestDisk, for example on the Linux Mint 19 I am using, it is TestDisk v7.0

More up-to-date versions can be found on some of the Rescue Disks also available to us, and there is also the command dd-rescue, and GParted also has a data recovery facility.

If using GParted, and you only have one Linux onboard (I have 80), then you need a GParted Live disk or USB, as you cannot work on your current OS with GParted.

TestDisk also has a "sibling" PhotoRec which can recovers photos.

Have a look at this article, I am not sure of its currency

https://www.ubuntupit.com/top-15-linux-data-recovery-tools-the-professionals-choice/

If I were you, I would carve off a separate partition on your drive, populate it with a few files and folders, and then try a couple of the tools to see what best suits your needs.

Cheers

Chris Turner
wizardfromoz
 

mohit tomar

New Member
Credits
0
Thanks Wizard from Oz..!!

I'am using Kubuntu 18.04.2 LTS / 4GB RAM / i3 6006u / Dell Vostro 3568

By the way I was trying to investigate how mv command works, and somewhere I read that it just changes the inode of the files so I guess that files are still there only the inodes got changed.

Actually I'm pretty new to Linux and going through the book TLCL by Willam E. Shots, Jr. I find it quite helpful, in fact good for a newbie like me.

I will surely follow your advice and will try to see what fits best for me... :) :) ;)
 

wizardfromoz

Super Moderator
Staff member
Gold Supporter
Credits
7,500
Oh, Socko, you bugger, don't scare him :D

dd is like the Australian dingo - it has gathered a bad reputation, that is not really deserved :p

Mohit, mistakes can be made at the command line even by experts, and it is usually not the fault of the command, but of the user.

PEBKAC - Problem Exists Between Keyboard And Chair :D, is a saying we have.

If you are planning to engage in a major task such as what went wrong, you are best off installing Timeshift on your Kubuntu, taking a snapshot before the exercise, and then if something goes wrong, you can roll back your system.

Then dedicate one USB stick to making a Live USB of Linux Mint 18.3 or 19 (or even a Linux Lite 4). Why? Because these Distros ship with Timeshift installed, and the Live stick can be used to track down and restore from a snapshot.

See my Tutorial on Timeshift at https://www.linux.org/threads/timeshift-similar-solutions-safeguard-recover-your-linux.15241/

and if you have any questions, ask there.

Cheers

Chris Turner
wizardfromoz
 



Latest posts

Top