You Are My Sofa

Sunday, July 10, 2011

How I accidentally deleted everything from my Dropbox (and then recovered it again)

How I deleted everything


I had dropboxd running on a headless Linux box, but at some point I stopped running it and deleted ~/Dropbox altogether. Thought nothing more of it.

Today, I decided I needed it back, so I ran dropboxd again. It helpfully reminded me that I had deleted my Dropbox dir:

$./dropboxd
Couldn't locate your Dropbox folder. Did you move it somewhere?


Ok, cool, so I just need to mkdir ~/Dropbox. No problem. Done.

Then a minute later I see this notification pop up on my desktop: "481 files have been removed from your Dropbox folder." Cue flipping out, and verifying on the Dropbox website that yes, I have removed 481 files and 171 folders. Unfortunately I didn't see any way to revert that change.

Why it happened


Of course, I had had Dropbox set up on this box before, so it knew what files it should be seeing, from the last time it ran. And when I re-created that folder, to Dropbox it appeared that I had simply deleted everything in it.

Had I thought to rm ~/.dropbox/filecache.db and maybe rm ~/.dropbox/sigstore.db, it would simply have thought I never had any files, and performed a sync from scratch.

But I didn't had thought to did that.

How I fixed it


This isn't a perfect fix, but I thought, hey, what if I delete the db files from my laptop's installation? It's been in sleep mode this entire time, and I can turn it on without a network connection, stop Dropbox, delete those files, and then when I restart Dropbox it'll think they're all newly-added files from this computer. It'll also give me a chance to make a copy of my laptop's Dropbox folder.

And as a bonus, Dropbox is smart enough not to re-upload files it recognizes are the same locally as remotely, even in the absence of its file cache database.

Less than 5 minutes later, my laptop has re-submitted the recently-deleted files to my Dropbox account, and both my desktop and headless box have re-downloaded them. The event log on the Dropbox site informs me that after deleting 481 files and 171 folders, I then added 481 files and 171 folders. Cool. And one conflicted file that I had updated on my desktop after putting my laptop to sleep yesterday. Easily fixed.

My full process to restore the files:
  1. Kill the rogue deletion dropboxd process
  2. rm -fr ~/.dropbox (just to be safe — meant I had to re-link the computer to Dropbox)
  3. Turn off wireless switch on laptop
  4. Turn on laptop
  5. Quit Dropbox
  6. Back up Dropbox folder
  7. Erase filecache.db and sigstore.db from C:\Users\me\AppData\Roaming\Dropbox\
  8. Start Dropbox
  9. Watch as it compares the contents of my local folder against the repository, re-uploading the accidentally deleted files and pointing out my not-deleted conflicted file


Other thoughts


Dropbox keeps a history of all your files and their contents in its versioning system. Even if you delete a file, it's still stored on the server; for me, this fell apart because the UI lacked a way to undo an entire "event". In order to restore my files, I would have to go into every folder and identify the most-recently-deleted files to restore them. A large number of the stuff deleted was various backups of SD cards and stuff with lots of contents; not really feasible to do that one folder at a time.

The fix I used worked for me because I didn't actually delete ALL my files, and I assumed (correctly, I believe) the only files that got removed were all present and unmodified on my laptop compared to their state immediately before removal. That meant my laptop was able to upload them all and restore the state of the repository as a whole. The conflicted file was handled in a particularly sane manner, and it stood out on the event list.

Of course, you could create a support ticket and ask them to undo your mistake too. That would be a lot less work, and they seem to be pretty quick about it.

3 Comments:

  • Your target is the local partnership services firm, you can shoot a professional looking video yourself.


    Feel free to visit my webpage - seo optimization services

    By Anonymous Anonymous, at May 08, 2013 12:00 AM  

  • Thank you so much, this was exactly the info I was looking for. This saved our small business a ton of time and work. We were able to reverse the changes made by a mistake which erroneously updated thousands of files in just a few simple steps.

    By Anonymous Anonymous, at October 03, 2013 6:15 PM  

  • Losing vast amount of files and folders like yours can be very annoying! Good thing you were able to recover them and re-upload all of the deleted files. I hope the event doesn't happen ever again. Though your process seem easy, it’s still a hassle and never-wrecking. Thanks for sharing!

    Lillian Walker @ Taylor Works, Inc.

    By Blogger Unknown, at August 18, 2014 3:11 PM  

Post a Comment

<< Home