How to i restore an overwritten file?

Hello, i had a dbf file created by QGIS stored on a usb disk. I moved that file on a sub directory and then back to the original, when i moved it back by a mistake i rewrote it with an empty dbf file with the same name. My original file had info for about 600 polygon’s so it’s very important for me to recover it. Is there any way to do that? Can anyone to help me?

  • _OpenMandriva Lx version:_5

  • Desktop environment (KDE, LXQT…): KDE

  • Description of the issue (screenshots if relevant):

  • _Relevant informations (hardware involved, software version, logs or output…):_Operating System: OpenMandriva Lx 5.0
    KDE Plasma Version: 5.27.9
    KDE Frameworks Version: 5.112.0
    Qt Version: 5.15.11
    Kernel Version: 6.6.2-desktop-1omv2390 (64-bit)
    Graphics Platform: X11
    Processors: 8 × Intel® Core™ i7-8550U CPU @ 1.80GHz
    Memory: 7.7 GiB of RAM
    Graphics Processor: Mesa Intel® UHD Graphics 620
    Manufacturer: ASUSTeK COMPUTER INC.
    Product Name: X542UAR
    System Version: 1.0

1 Like

see with

  • PhotoRec is specialised in video, documents and archives from hard disks, CD-ROMs, and lost pictures from digital camera memory (thus the Photo Recovery name).

Contrarily to popular belief TestDisk can recover anything, but (and that’s a big but):

  • testdisk takes more time to recover a file as it’s a generic tool, not specialised in anything, contrarily to PhotoRec.

Without filesystem snapshots or another backup somewhere, you will need to use a restore utility like the ones mentioned.

@zeroability @stephane Well, before i ask here i had already tried the PhotoRec and i had setup it to search only for dbf files, unfortunately the results wasn’t good it brought me back 877 dbf files which had size 25.9 gb, this one which have one column and 4 rows have 2 gb size


so something went very wrong here. When i am searching in the content of all this files for i find one which have the text which i had on my columns no one seems to have it…
I think i should to describe what i did when i lost the dbf file. I had a folder of a work on my usb there was some sub folders with contents some info and papers of my customers, on the main folder was also between other files, the files which the QGIS created the shp, dbf, shx, and prj files. After i upgrade from OM4 to OM5 every time which i opened that main folder I was getting a message about the kioslave has crashed.

I decided to find what causes that issue, i made one more sub folder and i started to move files from main to it, when i moved the shp files bingo i got the crash message, i went back to main folder there don’t was crash any more. On my laptop and on my usb’s i have many shp files which don’t causing any problem, so on this point i thought to create a copy of the problematic shp files to i see if them continue giving me the crashes. Back to QGIS i made an empty new shp with the same name with the original which it stored on my main folder and here i did the big mistake before i copy the polygons of the old shp to the new, i moved the accompanying dbf file back to the original folder when i got the message there was another file with the same name I allowed the original file to be overwritten by the new empty, the catastrophe!
Now, since i don’t have snapshoots or buckups of my usb, since the original file overwritten by the empty and since the PhotoRec seems not did the job well, i think the only way is to i try to recover it of the folder which it was stored for few mins without any change. I don’t know if the TestDisk can do that i have use it less than PhotoRec and i am not familiar with it, when i tried on some point i get that and i stop

This can sometimes be permissions. Especially if you are working directly from a USB that was a backup from a different distro. The UID’s don’t always align with other distros and it can’t tell who owns the file so it errs on the side of caution.

You are rapidly approaching the need for professional data recovery services. This should help with both utilities:

This is the company the IT consultancy I used to work at uses:

https://drivesaversdatarecovery.com/

Good luck.

1 Like

@zeroability thank you! Well, i think i did it, i used the TestDisk i navigated on the folder and i think i found the file which i wanted, i copied it on my home but i can’t open it it says me the file is not exists, i guess that because is a root file when i using the konsole i get this


So there is! How can i unlock it rename it and use it as a regular user file?

I believe it is:

sudo chown <your_username>:<your_username> <filename>.<file_extension>

Where <your_username> replaces your username, etc…

@zeroability @stephane guys thank you very much for your help! I got my file very easy with TestDisk , but i had difficulties to open it. After a lot of tries i found the problem was on the name of the file which it was on greek characters, i renamed it with mv command as root and the file opened and it was exactly like i left it the last time. Unfortunately the specific ones shp files continue causing the crash on kioslave

after some tests i found that when the shp is on a folder alone nothing is happening, when is together with the shx file causing the crash, but it necessary the shp, shx dbf,and prj files to be on the same folder to work’s.

You should still check the permissions of the files. Make sure they have your username and not a number:

ls -la

I would also make a copy of the files on a disk that is not the one you restored the file from just in case you need to go back to it and pull another restore. Do this before you start modifying file contents and permissions.

I don’t know how many people here use QGIS so support may be limited. It may require that you contact the project to get more information and additional steps to resolve this issue.

@zeroability Thank you, i am the owner and i already has did copies, i guess it needs to l look for this issue of the QGIS side…

1 Like