Shall I recover a Seafile storage, recreating a new seafile server and connecting it?

Hi there,
I had a Raspberry PI2 with seafile server 6.0.4 and I kept storage on an external disk.
Seafile server was up and running flawlessly until last saturday, with ngnix + mysql + ssl certificates by Let’s Encrypt, while storage was symlinked to an external 2T usb disk …
Now … I went to a great trouble.
Last saturday I accidentally broke the microSD card where raspian, Seafile+ngnix+mysql were installed.
Unfortunately I have no backups (my terribly fault!) of /etc nor /var, no db backup, nothing … about my old server installation.

In your opinion, have I any chances to recover and use my external storage with cloud, if I try to replicate installation of Seafile server?? (even if my mysql db will be empty from scratch, etc…)

EDIT: I already reinstalled a new Seafile server, same version, running, but I can’t see my libraries / files, despite storage disk is still there, untouched.

Any suggestions?
Thank in advance.

Have you tried this?
https://manual.seafile.com/maintain/seafile_fsck.html

No, I didn’t try it yet…
I’m searching something able to re-create the db starting from an existing data directory.
Do you think it could work?

May be I should try on a copy of a data dir.
Thank you for reply.

Gabo.

I would like to know if this works too as I’m using the same configuration. Did you already try to recreate the db?

Yes, but unfortunately the db will not be rebuilt.
The only thing I can do, is to export all my storage with ./seaf-fsck --export , and since seaf-import.sh doesn’t exist in community version (and accordingly for Raspberry), I’m forced to upload again all recovered files manually… :frowning:

1 Like

I managed to recreate the seafile database from scratch with only having access to seafile-data (your data basically). This work on the community edition, and you don’t have to export your library and re-upload it again. I guess you have already solved it by now but I post my solution for others to read if they manage to break their installation.

Note that only the data is restored. Everything about shared folders, libraries, groups etc are stored in the database, so that will be lost. What you will do is basically import your old libraries into a fresh seafile installation.

I did the following steps to get it working:

  1. Put seafile-data in some secure location (backup).
  2. Check the library uuid's to restore in seafile-data/storage/blocks/. You basically have to guess which one is which. You can use /seaf-fsck --export to get a better understanding what library uuid*s you want, but then you have to wait for your whole library to be exported. You can also just restore every library.
  3. Setup seafile server from scratch in an empty folder. You can use the old one if you clean it out. Remember to move seafile-data to someplace safe beforehand.
  4. Start seafile server
  5. Login as admin in web-ui and recreate user accounts.
  6. Stop seafile server (just in case).
  7. You need to replace the new “empty” seafile-data directory with the old one from step 1.
  8. Run ./seaf-fsck --repair <library-uuid-to-restore>.
  9. Use a mysql client to make seafile aware of the lost libraries (or sqlite3 if you use that instead of mysql/mariadb). Do the following (replace values between <tags>):
    • use seafile_db;
    • select * from Repo;
    • insert into Repo (id, repo_id) values (<pick-unique-id>, “<library-uuid-to-restore>”);
    • select * from RepoOwner;
    • insert into RepoOwner (id, repo_id, owner_id) values (<pick-unique-id>,"<library-uuid-to-restore>", “<email-to-user-account-of-repo-owner-from-step-5>”);
  10. Now your seafile database should be fine. Start seafile again and if you have done it right, you should have access to your old files.
2 Likes

Great job. Didn’t know this is possible without the DB.

If you find any further drawbacks while running the new server and you fix them it would be nice if you would add this Information here.

I will save your guidelines in my seafile documents. Thanks alot m8

Thanks!

I actually didn’t have a seafile server breakdown. I just wanted to make sure it it was possible, and how hard it was to restore a broken seafile server. I’m changing my storage backend to use glusterfs so that I can have a distributed storage backend, so I wanted to test that setup out with a test seafile server. While doing that, I managed to break the storage backend when removing a brick (disk) from glusterfs (some files in mariadb apparently failed to migrate to other bricks, and I had already cleaned removed disk), so I thought this is a perfect opportunity for testing how good seaf-fsch is and if I can restore my data in seafile-data that was broken while fiddling around with gluster storage backend. In my test setup I had a few files, maybe 1 GB of data when it broke.

After restoring the database, I did notice that seahub estimated the repository size to be 0, even though it was filled with content. This was fixed by simply restarting seafile server, or maybe you just have to wait for the server to calculate the size, I’m not sure exactly how that was fixed. Otherwise, nothing strange :slight_smile:

I also want to add that this was done with a seafile server v7.0.3.

1 Like