Hi everybody. So something crazy happened for the first time which has never happened to me before and I’ve never had an issue with Kate before today. I mostly utilize Kate to also document and file important and often trivial texts and over the years I’ve created many kate documents or files if you want to to call it that with thousands of lines of texts.
I had opened a regular kate text file I’d been using for a long time, maybe close to a year, so I’ve saved and edited the file hundreds of times without fail, so as you can imagine there was a lot of stuff inside it. I’d opened the same file yesterday copy and pasted just typical online formation, general notes and articles but I didn’t save anything; I should note, not saving the recent input isn’t really crucial so I didn’t bother saving immediately as there wasn’t really anything important.
This is where the crazy thing happened, I still had the kate file open and as I went to press save, it would allow me and it actually promoted with something saying I can’t save the file but I wasn’t overly fussed because I’ve already saved that same file hundred of time before so it not saving the most recent information isn’t crucial so I closed the file. Then I realised that the prompt that came up only appeared because my drive space was critically low. I deleted and moved some data around and went to open up that same kate file that I’ve always used hundreds of time with so much important information and most of the data inside it completely disappeared, which is crazy considering I hadn’t actually done anything to the file.
I closed it and tried to reopen the same file again because quite often Kate allows you to brilliantly recover any data due to unforeseen issues but it typically notifies you of this but kate didn’t issue this and most of the data is still gone.
Could someone please give me any suggestion to recover the data. I’d greatly appreciate it. Thanks
Kate swap files (used for crash recovery) are hidden files typically stored in the same directory as the original file, named as .filename.ext.kate-swp . They are generated only for files that have been previously saved … and are deleted upon a normal save.
(Notice the swap file is preceded by a dot . , so is a hidden file)
Thanks for the reply, I greatly appreciate it Could you perhaps direct me to where the directory is for that specific file? I searched “.filename.ext.kate-swp” in ‘/’ but it didn’t find it. I also searched for the kate folder but there were so many.
If the “backup” file does exist, then the default location is in the same sub-directory where the original file is | was (unless you changed where they are stored). Because the backup’s filename begins with a . (dot), then it’s a hidden file … so it’s like this:
The first “ls” output won’t show hidden files … the “ls -al” will show, as in second output"
It is your backup-policy, choise of tool(s) and implementation isn’t it.
I, and most probably @knurpht , can tell you where our backups are stored, but that will not help you I guess.
Guys, it seems clear that this user doesn’t have a backup strategy in place, so telling them to “restore from backup” is not particularly helpful at this juncture. If they had a backup, they wouldn’t be asking for help recovering an accidentally deleted file. They should definitely look into getting a backup strategy (or other DR plan) in place to prevent the next data loss scenario, but the horse has already left the proverbial barn this time around.
@Numan_Suse - an important thing to consider in data recovery is that nothing more gets written to the drive. Depending on the drive technology in use, it’s possible that the file is not recoverable as the blocks it was stored in may have been overwritten, in which case a swap file (as myswtest suggested) is probably your best option.
Continuing to use the system, however, is going to make it less likely that you can recover the file as the odds increase with every file written that the data is simply going to be overwritten.
You might take a look at the photorec utility for recovery. If your system is partitioned so the home directory structure is in a separate partition, then you may be able to install this safely. I would recommend using your phone, tablet, or another computer to read up on the utility to see how to use it. If the partition is the same, then look to use a live USB on the system so you avoid writing additional data to the drive itself.
If the available space is critically low then, no application on this planet, including Kate, will be able to write crash recovery files – there ain’t no space left on the drive to write the required file recovery data.
If the bucket’s full, it’s full – you can’t continue to fill it with anything …
Yes, yes, I know, a bad example – disk space doesn’t overflow – it simply fills up until it’s full …
Lesson to be learnt – always keep an eye on your available disk space when using a computer.
I understand that nothing more of course can get written to the device but the crazy thing is, opening the file now looks as though I did ctrl+A and then pressed the backspace key which of course I did neither.
@myswtest this is what shows up and for anybody else reading there must be a backup because on occasions when I’ve turned of the computer by accident or a random system shutdown occurred, the kate editor would seemingly give me an option to restore any data.
I hadn’t actually saved anything on the file, it wouldn’t allow me to. It stands to reason that the file should just remain the way it is before I saved anything on it for that particular session without any kind of error but low and behold after the next system turn on, most of the data is gone.
Why not just tell me where it is stored then and why would you think it would not help me seeing as I can just cop/cut and paste all the information that is on the backup?
In this thread, when @knurpht Replied with:
“Restore it from your backup.”
… that is one of those responses that is a reference to “don’t you occasionally back up your system? Then check the latest backup copy from there”.
Personally, I use “rsync” once a week to back-up my /home/* sub-directory tree. That way, all my important documents and photos, etc are backed up to an external (USB-connected) “backup drive” … and then I use rsync to copy my /home/* to another computer on my network. Some folks back up (like businesses) once a day.
In the computer industry, it’s always recommended to back up your system in case there is a catastrophic failure of the hard disk or whatever the storage device is that’s being used. Some folks use Timeshift, BorgBackup, RescueZilla, Bacula, etc, etc.
Thanks for checking and showing the list of files.
Okay, the important question … that is a list of files in (I assume) your “home” sub-directory only. The question … is THAT the sub-directory where you always saved that “lost” file??
That can perhaps happen if you save to a device that’s full - it attempted to recreate the file and write it, found that there was no space, and then closed it with the error you received.
Given that the disk was critically low on space, the chances that there’s anything to recover are fairly small. Photorec is probably your best option, as I suggested previously. If it doesn’t find it, then there’s no data to find, because it ignores the filesystem and looks at the blocks on the drive. If it doesn’t find strings that were in the document, they don’t reside on the disk any more.
Okay … if there is a “Kate backup”, and you’re not confident where it exists, read my two “find” examples below.
In the first example, I just want to find ANY filename ending with “kate-swp”. You will see that find found one Kate Backup Swap file.
In the second example, I want to find ANY filename that contains “zupdate”. Notice find found two files … the original file “zupdater.txt” and the Kate Backup.
The last example is simply the result of “ls” for that exact sub-directory content.
… in your case, you might not find the “original filename” (or the backup). But find is a quick way to search throughout your user’s home sub-directory tree.