Recover library with 0 byte files

solved

#1

Hi,

My library was unavailable and I ran a ./seaf-fsck.sh --repair on my server.
This command replaced the size of all files in my libraries to 0 byte files.

Now that my library is available, I’d like to recover these files ('cause if I try to download them, I’m just downloading 0 byte files).
I tried to run ./seaf-fsck.sh --repair but the program didn’t find any errors and didn’t change anything.

Do you know how can I solve that ?

Thanks


#2

IMO, the solution would be to force seaf-fsck to re-check the file size and replace it with the right one.

I guess I can do that by replacing the file size value in the database.
Do you know which table / field can help me?


#3

Is this a bug ?


#4

Exporting Libraries to File System

Since version 4.2.0, you can use seaf-fsck to export all the files in libraries to external file system (such as Ext4). This procedure doesn’t rely on the seafile database. As long as you have your seafile-data directory, you can always export your files from Seafile to external file system.

The command syntax is

cd seafile-server-latest
./seaf-fsck.sh --export top_export_path [library-id1] [library-id2] …
The argument top_export_path is a directory to place the exported files. Each library will be exported as a sub-directory of the export path. If you don’t specify library ids, all libraries will be exported.

Currently only un-encrypted libraries can be exported. Encrypted libraries will be skipped.


#5

Thanks for the replies @DerDanilo and @arjones85

@DerDanilo I’m not sure if this is a bug, I don’t know what is the expected behavior of seaf-fsck in that case.

@arjones85 This is not gonna work in ;y case as the libraries I want to export are encrypted. Also, if I export the files I will be able to get back the files. However, I would have to re-import them into Seafile. What I want to do is to fix the imported libraries.

Also, the libraries I’m using are using a Object Storage backend (Amazon S3-like, but with the Openstack swift API).


#6

This more looks like the files content has been lost due to a hardware / storage failure and seaf-fsck could not recover the contents.


#7

@GNUletik what provider do you use for the object storage?


#8

I’m using OVH. I checked the repositories and there was no changes on the files since I messed up the library.
I don’t think the files are corrupted.


#9

Hmm, it don’t seems to be very likely that the object storage did fail.

When you go to the file history, are there older entries?


#10

Nice catch @shoeper, the files in the file history have the right size and I can download them.

Is there a way I can restore every files to an older version? Or another way to restore them as current files?


#11

When viewing a snapshot there is a recover button on the top right. I think that is what you need.

Looks like seaf-fsck created a new commit where all files are empty and choose it as the most recent one. There are no logs from running seaf-fsck, are there? That looks a bit like seaf-fsck was not able to access the stored blocks which led it believe they would be lost.


#12

Works like a charm ! I Didn’t know this was possible.
Thank you so much @shoeper :slight_smile:

That’s exactly what seaf-fsck did.
But I don’t have anymore the logs from seaf-fsck. I just remember there was lines saying “Replacing with 0 byte files”.

Thanks again :slight_smile: