Home | Send Feedback

Self-host Seafile

Published: February 04, 2019  •  linux

Seafile is an open-source file sync and share software. You can upload files and sync them across different devices. Seafile provides a web interface but also native clients for macOS, Linux, Windows, and for the mobile platforms Android and iOS. These clients share the files across the different devices, Seafile also provides drive clients that enable you to access files on the server without syncing to a local disk, like a network drive.

You can use Seafile by subscribing to a hosting provider. But in this tutorial, we are going to self-host Seafile and install it on a LightSail server from Amazon. I'm testing this on the cheapest LightSail server that costs $3.50 and includes 20GB of disk space. If you are looking for VPS with much more disk space, I recommend looking at Contabo: https://contabo.com/?show=vps
For 324 EUR a year, you get a server with 1600 GB disk space.

In this tutorial, I'm going to install the free Open Source Edition of Seafile. There is also a Pro Edition available, which is also free for up to 3 users, but for this tutorial, I don't need the additional features of the Pro Edition. Check out this page to view the differences between Open Source and Pro Edition.


Before I start setting up the server, I installed a subdomain. This is needed if you want to use TLS, which is highly recommended. For this demo I use the domain sea.ralscha.ch

In the web console of my DNS provider, I inserted an A record that points to the IP address of my LightSail VPS.

sea.ralscha.ch.        86400   IN      A

I also recommend adding a CAA record, if your DNS provider supports this feature. Either for the whole domain if you get all your certificates from one CA or just for the subdomain if you use multiple certificate authorities.

ralscha.ch.             86400   IN      CAA     0 issue "letsencrypt.org"
// OR
sea.ralscha.ch.        86400   IN      CAA     0 issue "letsencrypt.org"


If you want to follow this tutorial and also use a Lightsail VPS, go to my previous blog post and follow the instructions until, but without, the section Install required packages. I selected Debian 9.5 as the operating system.

Connect to your VPS and upgrade the installed packages

ssh -i lightsail admin@
sudo apt update && sudo apt dist-upgrade

lightsail is the name of my private key file.

The easiest way to install Seafile is with a Docker container. For that, we need to install Docker first. For the Docker installation, I follow the instructions on this page:

sudo -i
apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg2 \
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
apt-key fingerprint 0EBFCD88
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/debian \
   $(lsb_release -cs) \
apt-get update
apt-get install docker-ce docker-ce-cli containerd.io

You don't have to use Docker. You can install Seafile directly on Linux. Doing it this way has the advantage that you have full control over the Seafile installation.

Visit the official documentation page for more information about this topic:


With a running Docker installation, we can now pull the Seafile image and start it. For the following steps, I follow the description from the Server Manual:

docker run -d --name seafile \
  -e SEAFILE_SERVER_HOSTNAME=sea.ralscha.ch \
  -e SEAFILE_ADMIN_EMAIL=me@ralscha.ch \
  -e SEAFILE_ADMIN_PASSWORD=a_very_secret_password \
  -v /opt/seafile-data:/shared \
  -p 80:80 \
  -p 443:443 \
  --restart unless-stopped \

Make sure that you specify the correct hostname, email, and a secure administrator password. This docker command maps the data directory /shared inside the container to the /opt/seafile-data folder of the host computer. You may change /opt/seafile-data if you don't like this location.

Also, make sure that you open the firewall ports on your VPS. For Lightsail, you do that in the Web Management Console.


If you are interested in installing the Pro Edition with Docker, visit this page:


Your Seafile installation should be up and running. If you open the web interface in a browser, a login screen should appear.


As an admin, you can set up more users in the System Admin section.

The first time you start a native client, he presents a dialog where you have to enter the server address and your login credentials. After that, it syncs the remote library to your local computer, and each time you add files locally, it syncs them to the remote server.


Upgrade Seafile

From time to time, you should upgrade your Seafile installation. To do that, you pull down the latest Docker image, delete the old container, and then start the container with the new image.

docker pull seafileltd/seafile:latest
docker rm -f seafile
docker run -d --name seafile \
  -e SEAFILE_SERVER_HOSTNAME=sea.ralscha.ch \
  -e SEAFILE_ADMIN_EMAIL=me@ralscha.ch \
  -e SEAFILE_ADMIN_PASSWORD=a_very_secret_password \
  -v /opt/seafile-data:/shared \
  -p 80:80 \
  -p 443:443 \
  --restart unless-stopped \


Out of the box, you usually don't have a backup on a VPS. Some VPS providers have snapshot tools where you can take a snapshot of the whole server. For a more mission-critical Seafile installation, you should look at installing a real-time backup system, where you install Seafile on two servers and install a link between the two servers, which copies everything from the main to the backup server in real-time.

See the documentation for more information:

In this section, I show you a simplistic approach where a script runs once a day and copies everything to an Amazon S3 bucket.

If you follow this tutorial, first request the necessary access_key and secret_key from Amazon by following the steps in my previous blog post

Make sure that the policy you install contains the following 5 actions. The script utilizes s3cmd with the sync option, which copies only changed files to S3. To do that, it needs a bit more permissions than just PutObject.

    "Version": "2012-10-17",
    "Statement": [
            "Sid": "VisualEditor0",
            "Effect": "Allow",
            "Action": [
            "Resource": [

Install the Amazon S3 command-line tools.

sudo -i
apt install s3cmd 

In the /opt folder create a new script called backup-seafile and paste the following code.

rm -fr /opt/seafile-backup
mkdir /opt/seafile-backup
cd /opt/seafile-backup
docker exec -i seafile mysqldump  -uroot --opt ccnet_db > ccnet_db.sql
docker exec -i seafile mysqldump  -uroot --opt seafile_db > seafile_db.sql
docker exec -i seafile mysqldump  -uroot --opt seahub_db > seahub_db.sql

cp -R /opt/seafile-data /opt/seafile-backup
cd /opt/seafile-backup/seafile-data && rm -rf ccnet

s3cmd --access_key=AKIA... --secret_key=l56SjC+... sync /opt/seafile-backup s3://ralschaer.sefile

Make the script executable

chmod 700 backup-seafile

Next, install a timer service in systemd. This takes care of starting our backup job daily at the specified time.

Create a file seafile-backup.timer and paste this code into the file.

Description=Run seafile-backup once a day

OnCalendar=*-*-* 05:00:00


Change OnCalendar if you want to run this script on a different time or more often than just daily. See the documentation for information about the supported format: https://www.freedesktop.org/software/systemd/man/systemd.time.html

Create the systemd service file seafile-backup.service and paste this code into the file



Then link these files into the systemd folder, reload systemd, start and enable the timer

ln -s /opt/seafile-backup.timer /lib/systemd/system/seafile-backup.timer
ln -s /opt/seafile-backup.service /lib/systemd/system/seafile-backup.service
systemctl daemon-reload
systemctl start seafile-backup.timer
systemctl enable seafile-backup.timer

Check if the timer is installed properly

systemctl list-timers

Manually start the job.

systemctl start seafile-backup
journalctl -u seafile-backup

To recover a backup visit the chapter Recovery in the official documentation:

This concludes the tutorial about self-hosting Seafile. A powerful file sync software and a good alternative to Dropbox, Google Drive, and others. Self-hosting software gives you more control over the data, but don't forget if you install something on a VPS that not only you have access to the data but also the VPS provider.