First of, you need to download seafile to be able to use the seaf-fsck tool. If you are on a windows computer you can also use ubuntu via wsl.
Download & extract seafile
sudo apt -y install wget
export VER="7.1.3"
wget https://download.seadrive.org/seafile-server_${VER}_x86-64.tar.gz
sudo tar -xvf seafile-server_${VER}_x86-64.tar.gz -C /srv
sudo mv /srv/seafile-server-${VER} /srv/seafile
The seafile-fsck tool that we will use to recover the files is only working with a valid ccnet configuration. Because we don't want to re-setup the databases we will install sqllite and create a dummy installation.
jfwenisch@host:/srv/seafile$ sudo apt-get install sqlite3
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libsqlite3-0
Suggested packages:
sqlite3-doc
The following NEW packages will be installed:
sqlite3
The following packages will be upgraded:
libsqlite3-0
1 upgraded, 1 newly installed, 0 to remove and 110 not upgraded.
Need to get 1251 kB of archives.
After this operation, 2482 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 libsqlite3-0 amd64 3.22.0-1ubuntu0.4 [499 kB]
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 sqlite3 amd64 3.22.0-1ubuntu0.4 [752 kB]
Fetched 1251 kB in 2s (731 kB/s)
(Reading database ... 29254 files and directories currently installed.)
Preparing to unpack .../libsqlite3-0_3.22.0-1ubuntu0.4_amd64.deb ...
Unpacking libsqlite3-0:amd64 (3.22.0-1ubuntu0.4) over (3.22.0-1ubuntu0.3) ...
Selecting previously unselected package sqlite3.
Preparing to unpack .../sqlite3_3.22.0-1ubuntu0.4_amd64.deb ...
Unpacking sqlite3 (3.22.0-1ubuntu0.4) ...
Setting up libsqlite3-0:amd64 (3.22.0-1ubuntu0.4) ...
Setting up sqlite3 (3.22.0-1ubuntu0.4) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1) ..
Afterwards change into the seafile directory and run setup-seafile.sh. You'll be ask for a name, ipaddress and port. Enter a random name and port and use 127.0.0.1 as IP Address
cd /srv/seafile
sudo ./setup-seafile.sh
-----------------------------------------------------------------
This script will guide you to config and setup your seafile server.
Make sure you have read seafile server manual at
https://download.seafile.com/published/seafile-manual/home.md
Note: This script will guide your to setup seafile server using sqlite3,
which may have problems if your disk is on a NFS/CIFS/USB.
In these cases, we suggest you setup seafile server using MySQL.
Press [ENTER] to continue
-----------------------------------------------------------------
Checking packages needed by seafile ...
Checking python on this machine ...
Find python: python3
Checking python module: python-sqlite3 ... Done.
Checking for sqlite3 ...Done.
Checking Done.
What would you like to use as the name of this seafile server?
Your seafile users will be able to see the name in their seafile client.
You can use a-z, A-Z, 0-9, _ and -, and the length should be 3 ~ 15
[server name]: wsl
What is the ip or domain of this server?
For example, www.mycompany.com, or, 192.168.1.101
[This server's ip or domain]: 127.0.0.1
What tcp port do you want to use for seafile fileserver?
8082 is the recommended port.
[default: 8082 ] 8082
This is your config information:
server name: wsl
server ip/domain: 127.0.0.1
seafile data dir: /srv/seafile-data
fileserver port: 8082
If you are OK with the configuration, press [ENTER] to continue.
Generating ccnet configuration in /srv/ccnet...
done
Successly create configuration dir /srv/ccnet.
Generating seafile configuration in /srv/seafile-data ...
Done.
-----------------------------------------------------------------
Seahub is the web interface for seafile server.
Now let's setup seahub configuration. Press [ENTER] to continue
-----------------------------------------------------------------
Creating database now, it may take one minute, please wait...
/srv/seafile
Done.
creating seafile-server-latest symbolic link ... done
-----------------------------------------------------------------
Your seafile server configuration has been completed successfully.
-----------------------------------------------------------------
run seafile server: ./seafile.sh { start | stop | restart }
run seahub server: ./seahub.sh { start <port> | stop | restart <port> }
-----------------------------------------------------------------
If the server is behind a firewall, remember to open these tcp ports:
-----------------------------------------------------------------
port of seafile fileserver: 8082
port of seahub: 8000
When problems occur, refer to
https://download.seafile.com/published/seafile-manual/home.md
for more information.
Seafile automatically created a data directory within /srv/seafile-data To recover the files, we will rename the created directory and create a symbolic link pointing to the our directory from which we want to recover our data.
Move the empty seafile-data dir out of the way
sudo mv /srv/seafile-data/ /srv/seafile-data-dummy
Create a symbolic link on it's position. Make sure to replace ' /mnt/d/seafile/seafile-data' with the folder you want to recover from
sudo ln -s /mnt/d/seafile/seafile-data /srv/seafile-data
Check the symbolic link and the folder structure. It should look like this:
jfwenisch@host:~$ ls -l /srv/
total 960
drwx------ 1 root root 512 Sep 13 12:19 ccnet
drwx------ 1 root root 512 Sep 13 12:19 conf
drwxr-xr-x 1 root root 512 Mar 26 04:30 seafile
lrwxrwxrwx 1 root root 27 Sep 13 12:40 seafile-data -> /mnt/d/seafile/seafile-data
drwx------ 1 root root 512 Sep 13 12:35 seafile-data-dummy
lrwxrwxrwx 1 root root 7 Sep 13 12:19 seafile-server-latest -> seafile
drwxr-xr-x 1 root root 512 Sep 13 12:19 seahub-data
-rw-r--r-- 1 root root 958464 Sep 13 12:19 seahub.db
jfwenisch@host:~$ ls /srv/seafile-data
httptemp library-template storage tmpfiles
Now we can recover the files from the directory using ./seaf-fsck.sh (within /srv/seafile). The tool requires 2 arguments when used with the export option, an output path and the library-id which should be exported. To find out the library id inspect the folder you want to backup from and inspect the directory name within the blocks subfolder
jfwenisch@host:~$ sudo ls /srv/seafile-data/storage/blocks
3f63b7de-dedc-4bfe-be0b-3e3a9195b546 c2cfb761-3700-4b94-8a67-d33b08223e9c
83a81108-0027-4e41-90f7-14dfa9811f35 ee15cd35-d65d-4bb8-bc87-7889567006ae
Now you can export the library to folder of your choice. Replace '/mnt/d/recovered_data/' with your desired output folder and 'ee15cd35-d65d-4bb8-bc87-7889567006ae' with one of the ids you previously discovered.
jfwenisch@host:/srv/seafile$ sudo ./seaf-fsck.sh -E /mnt/d/recovered_data/ ee15cd35-d65d-4bb8-bc87-7889567006ae
Starting seaf-fsck, please wait ...
[09/13/20 12:40:50] fsck.c(986): Scanning available commits for repo ee15cd35-d65d-4bb8-bc87-7889567006ae...
[09/13/20 12:42:38] fsck.c(1026): Find available commit a22c3a3c(created at 2020-04-18 02:17:16), will export files from it.
[09/13/20 12:42:38] fsck.c(1062): Start to export files for repo ee15cd35(Meine Bibliothek).
[09/13/20 12:42:46] fsck.c(929): Export file /mnt/d/recovered_data/ee15cd35_Meine [email protected]/seafile-tutorial.doc.
[09/13/20 12:42:46] fsck.c(929): Export file /mnt/d/recovered_data/ee15cd35_Meine [email protected]/logo.png.
[09/13/20 12:42:46] fsck.c(966): Export dir /mnt/d/recovered_data/ee15cd35_Meine [email protected]/Videos.
...