How do I recover a deleted file?

revision-history

#1

I had a file that I accidentally deleted and now it’s lost. Is there a way to undelete it?


Deleted the wrong file
Massive file loss - Anything to be done?
Need to restore entire workspace to previous date
Lost Code on Copy-Paste
#2

Cloud9 keeps a revision history of every file in your workspace, even the deleted or lost ones. To restore a deleted file, you just need to get to the revision history. To do that:

  1. Create a blank file and save it with the exact same filename of the one you’d like to restore, in the exact same directory it was in before
  2. Open the newly created file and it will be blank
  3. Click on File > Show File Revision History
  4. Restore to the desired point

This is a standard feature available to all users, paying or free. It is only available in hosted workspaces (not SSH workspaces).

Finding Deleted Files

It’s not always easy to remember the exact names and paths of each file you’ve ever edited. As long as you’re comfortable taking a couple extra steps, you don’t have to rely on human memory alone :wink: To find your files, you’ll need to find your collab.db file then dig through it a bit.

Finding collab.db

The collab.db file is the key to all revisions you’ve made in your workspace and it is the file used when you open up revision history. It is located at ~/.c9/<your number>/collab.db. Your number will be different for each workspace you’re in but it should be the only directory that is named with a number, not purely text.

We’ll make a copy of your collab.db file to your workspace directory so we can download it. You can do so using the following commands in the terminal.
$ cd ~/.c9
$ ls (after this command, look for the number mentioned above)
$ cd <your number>
$ cp collab.db ~/workspace/collab.db (you can copy this anywhere you want, we just want to be able to download it)

From there, you should see the file in your file list on the left (Navigate panel) so you can access it freely without affecting any of your existing file revision history.

Digging through collab.db

From here, you can either access this information from the command line (if you’re comfortable with the SQLite command line interface. You can also right-click it and download the file to your desktop to explore using a visual SQLite viewer, such as SQLite Browser.

No matter which method you use, you can now look through the Documents table and scan through the different entries for the path you need. Once you find the path you’re looking for, recreate the file at that path and restore the file :thumbsup:


How can I recover the deleted folder (directory) from the trash?
#3

It would be better if there is a recycle bin.


#4

Good thought, perhaps you could submit this and details of what it might entail in Community Feature Requests.


#5

2 posts were split to a new topic: Need to restore entire workspace to previous date


#6

Awesome feature! Just saved me a few hours to recreate a script


#7

You made my day :slight_smile:


#8

2 posts were split to a new topic: Deleted team, workspaces gone