I accidentally “rm -rf content” – my bad.
My deployment script only does git push public/ directory, not my project/ directory, thus no backup on my content/ – my bad, too.
In this case, is there a way to recover content/ directory from public/ directory?
The public directory contains the compiled static HTML.
Perhaps with some elaborate shell script you would be able to extract the several content pages and output them as separate Markdown files.
In any case we do not provide support for shell scripting in this forum. You would be better served by having a look at other forums like StackOverflow and the Ubuntu Forums.
By the way one of the very first things I learnt when I started working with UNIX is to be extra careful with the recursive delete rm -rf command.
That is why you need to store your project in Git version control to avoid catastrophes like the one you just had.
Anyway, I really hope that you manage to sort this out.
Good luck!
EDIT
There is a PHP library that converts HTML to Markdown. Never used it myself but have a look just in case it helps:
Since deleting files from the command line doesn’t put them into the trash, your only option IMO is to use a file recovery software. Google for “macos undelete files” or “macos file recovery”. The problem is that most such solutions will find a bunch of old files as well, and you probably loose the folder structure and the filenames, so even if you can recover the files, it will involve a deal of manual work to find out which file was which.
That is, unless you have a backup/time machine somewhere.
Thank you [onedrawingperday] [davidsneighbour] [fekete-robert]!
Taking all your suggestions, I firstly tried to recover files by installing extundelete, but couldn’t figure out installing “ex2fslibs” on my MacOS (High Sierra).
So, I ended up recovering all markdown files in content/ from index.html files from public/ by mixture of bash scripting and manual tweaking: 1) mostly extracting tags from html; 2) reusing the html body portion to the markdown files.
More importantly, I made sure pushing both my project/ and public/ to corresponding github repos.