Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Otherwise, you'll want to unount the partition, not write anything to it, and boot to a LiveCD and use a utility called "testdisk" (to prevent the file from being overwritten). You can get if from http://www.cgsecurity.org/ and through software.opensuse.org and possibly zypper. testdisk wasn't originally made for btrfs but it might be able to help you. The first few Google searches I skimmed through didn't have any better ideas.
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629
Rep:
I also read that "photorec" is very good at restoring files despite its somewhat misleading name. Never tried it myself and I believe it must be bought.
No, photorec is part of the "testdisk" package. Photorec is the tool to use here, not testdisk. Testdisk only restores partition tables.
A filesystem debugger would be a more surgical tool to recover one particular deleted file, instead of all and then searching through them. But I don't know if there is such a debugger for btrfs, and filesystem debuggers require a hell of learning to use.
Thanks guys for the posts. I was very lucky because there was a vi swp file and I managed to recover part of the code that I worked on
But for beying productive, what do you guys use to keep a automatic backup of your code/scripts and so on, what would be the method that works for you the best?
Distribution: openSuSE Tumbleweed-KDE, Mint 21, MX-21, Manjaro
Posts: 4,629
Rep:
I use backintime which can be configured to all your needs I'd say (backintime on my home setup, work is automated by the IT-department every 3 hours). Btw. I thought vim can do versioning?
You're using btrfs, take a snapshot. Takes no time, can be run anytime, and occupies (almost) no space.
Take a snap, back it up at your leisure while you are working.
For btrfs you'd better be conversant with the wiki - it has a page describing how to do your own incremental backups.
As to the original question, there are scripts on the net for recovering deleted (btrfs) files, but they are not foolproof. Use backups.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.