Skip to content

Migrate from non-docker Seafile deployment to docker

For Seafile cluster

This document is writting to about the single node, you have to do the following opeartions (except migtating database) in all nodes

The recommended steps to migrate from non-docker deployment to docker deployment are:

  1. Shutdown Seafile and native Nginx, Memcached
  2. Backup Seafile data (database also neet to backup if you are not use an existed MySQL database to deploy non-Docker version Seafile)
  3. Create the directory needed for Seafile Docker image to run, and recover the data. (If you are use an existed MySQL database to deploy non-Docker version Seafile, the data from database also need to recover)
  4. Download the .yml files and .env.
  5. Start Seafile Docker

Before Migration

Upgrade the version of the binary package to latest version, and ensure that the system is running normally.

Tip

If you running a very old version of Seafile, you can following the FAQ item to migrate to the latest version

Stop Services

Stop Seafile server

Run the following commands in /opt/seafile/seafile-server-latest:

Note

For installations using python virtual environment, activate it if it isn't already active:

source python-venv/bin/activate

Tip

If you have integrated some components (e.g., SeaDoc) in your Seafile server, please shutdown them to avoid losting unsaved data

su seafile
./seafile.sh stop
./seahub.sh stop

Stop Nginx, cached server (e.g., Memcached), ElasticSearch

You have to stop the above services to avoid losing data before migrating.

systemctl stop nginx &&  systemctl disable nginx
systemctl stop memcached &&  systemctl disable memcached
docker stop es && docker remove es

If you are not using an existed MySQL, you have to shutdown MySQL service too.

Backup Seafile

Please follow here to backup:

  • Backing up Databases (only if you are not using an existed database to deploy non-Docker version Seafile)
  • Backing up Seafile library data

Download the docker-compose files

You have to download the latest docker-compose files (i.e., series of .yml and its configuration file .env) in order to startup the relative services:

wget -O .env https://manual.seafile.com/12.0/repo/docker/ce/env
wget https://manual.seafile.com/12.0/repo/docker/ce/seafile-server.yml
wget https://manual.seafile.com/12.0/repo/docker/caddy.yml
wget -O .env https://manual.seafile.com/12.0/repo/docker/pro/env
wget https://manual.seafile.com/12.0/repo/docker/pro/seafile-server.yml
wget https://manual.seafile.com/12.0/repo/docker/caddy.yml

Then modify the .env according to your configurations.

Important

Do not use the .env in the non-Docker Seafile server as the .env in Docker-base Seafile server directly, which misses some key variables in running Docker-base Seafile. Otherwise the Seafile server may not work properly.

Create the directory and recovery data for Seafile Docker

In Docker-base Seafile, the default working directory for Seafile is /opt/seafile-data (you can modify them in the .env file). Here, you have to create this directory, and recovery from backuped file:

mkdir -p /opt/seafile-data/seafile

# recover seafile data
cp /backup/data/* /opt/seafile-data/seafile

Recover the Database (only if not use an existed MySQL)

You should start the services Firstly, otherwise you cannot connect to MySQL service (mariadb now in docker-compose Seafile):

docker compose up -d

After startuping the MySQL service, you should create the MySQL user (e.g., seafile, defined in your .env file) and add related permissions:

## Note, change the password according to the actual password you use
GRANT ALL PRIVILEGES ON *.* TO 'seafile'@'%' IDENTIFIED BY 'your-password' WITH GRANT OPTION;

## Grant seafile user can connect the database from any IP address
GRANT ALL PRIVILEGES ON `ccnet_db`.* to 'seafile'@'%';
GRANT ALL PRIVILEGES ON `seafile_db`.* to 'seafile'@'%';
GRANT ALL PRIVILEGES ON `seahub_db`.* to 'seafile'@'%';

Then you can follow here to restore the database data

Restart the services

Finally, the migration is complete. You can restart the Seafile server of Docker-base by restarting the service:

docker compose up -d

Success

After staring the services, you can use docker logs -f seafile to follow the logs output from Seafile to check the status of the server. When the service is running normally, you will get the following message:

Starting seafile server, please wait ...
Seafile server started

Done.

Starting seahub at port 8000 ...

Seahub is started

Done.