Skip to content

Upgrade Seafile Docker Professional Edition to 7.0

Starting with 7.0, we have adjusted seafile-docker image to use multiple containers. The old image runs MariaDB-Server、Memcached and Elasticsearch in the same container with Seafile server. Now, we strip the MariaDB-Server、Memcached and Elasticsearch from the Seafile image and run them in their respective containers. In order to be compatible with the data of the old container, you need to follow the process below to upgrade to the new version.

To prevent accidental old-fashioned upgrades, the new docker image has a new name called seafile-pro-mc (Seafile-Pro Multiple Container). The new image is configured and run using docker-compose.

Check the current container data

  • Suppose the current Seafile container's volumes directory is:/opt/seafile-data

So the data structure of the Seafile container should look like this:

/opt/seafile-data
├── db                <----------->     the data directory of MySQL
├── logs
   ├── seafile       <----------->     the logs directory of Seafile
   └── var-log
└── seafile
    ├── ccnet
    ├── conf          <----------->     the configuration directoy of Seafile
    ├── pro-data
    |   └── search/data/elasticsearch    <----------->     the data directory of Elasticsearch
    ├── seafile-data
    └── seahub-data

Modify MariaDB permissions

In the old container, the MariaDB user is only allowed to access through the '127.0.0.1' address. This permission is not enough in the new container, so you must first modify the permissions of MariaDB.

Allow root remote access

The root needs to be allowed to access the MySQL remotely by specifying a password. E.g:

  • Suppose the current Seafile container name is:seafile
  • Specify the access password of the root as:db_dev

Refer to the following command to allow root to remotely access MariaDB:

sudo docker exec -it seafile /usr/bin/mysql -e "grant all on *.* to 'root'@'%.%.%.%' identified by 'db_dev';"

Allow seafile remote access

Similarly, you need to allow seafile to access the MariaDB remotely with the specified password. E.g:

  • Suppose the current Seafile container name is:seafile
  • The seafile password needs to look at the PASSWD value in the current container's ccnet.conf configuration, assuming:467fa02f-bf9a-4afb-9300-c4683073162a
for database in {ccnet_db,seafile_db,seahub_db}; do sudo docker exec -it seafile /usr/bin/mysql -e "grant all on ${database}.* to 'seafile'@'%.%.%.%' identified by '467fa02f-bf9a-4afb-9300-c4683073162a';"; done

Modify the configuration file of Seafile

You also need to modify the MariaDB service address、Memcached service address and Elasticsearch service address in the configuration file of Seafile.

  • Suppose the current Seafile container name is:seafile

Stop the current Seafile container

First you need to stop the old container that is currently running.

sudo docker stop seafile

Backup configuration file

Back up the original configuration file of Seafile.

cd /opt/seafile-data/seafile
sudo tar -cf conf.bak.tar conf
cd conf

Modify the configuration file of Seafile

  • ccnet.conf:Change the HOST value to db in the [Database] configuration section ;
  • seafile.conf:Change the host value to db in the [database] configuration section ;
  • seahub_settings.py:Change the 'HOST' value to 'db' in the DATABASES dict,and change the 'LOCATION' value to 'memcached:11211' in the CACHES dict ;
  • seafevents.conf:Change the 'host' value to 'db' in the [DATABASE] configuration section, and add the following configuration in the [INDEX FILES] section:
external_es_server = true
es_host = elasticsearch
es_port = 9200

Migrate MariaDB data

Backup the data of MariaDB

cd /opt/seafile-data/
sudo tar -cf db.bak.tar db

Migrate the data's directory of MariaDB

Migrate the db directory out of the volume directory of the old container, so that the new MariaDB container can be used to mount the original data. If the directory is migrated to the /opt/seafile-mysql directory:

sudo mkdir -p /opt/seafile-mysql
sudo mv db /opt/seafile-mysql

Migrate the data's directory of Elasticsearch

Copy the data directory of Elasticsearch generated in the old container to a new directory and mount it when the new container runs. If you migrate the directory to /opt/seafile-elasticsearch/data:

cd /opt/seafile-data/
sudo tar -cf elasticsearch-data.tar seafile/pro-data/search/data/elasticsearch
sudo mkdir -p /opt/seafile-elasticsearch/
sudo mv seafile/pro-data/search/data/elasticsearch /opt/seafile-elasticsearch/data

Download the Seafile images

Login the Seafile private registry and pull the Seafile image:

docker login {host}
docker pull {host}/seafileltd/seafile-pro-mc:latest

You can find the private registry information on the customer center download page.

Modify the docker-compose.yml

Professional Edition:Download docker-compose.yml sample file to the host.

According to the actual situation, modify the docker-compose.yml, mainly the following:

  • The password of MySQL root ( MYSQL_ROOT_PASSWORD and DB_ROOT_PASSWD ), should be set to the root password above,such as:db_dev;
  • The volume directory of MySQL data ( volumes ), should be set to the directory after the migration above, such as:/opt/seafile-mysql/db:/var/lib/mysql;
  • The volume directory of Elasticsearch data ( volumes ),should be set to the directory after the migration above, such as:/opt/seafile-elasticsearch/data:/usr/share/elasticsearch/data ;
  • The volume directory of Seafile data ( volumes ),should be set to the directory of the old container's volume, such as:/opt/seafile-data:/shared .

Run new container

Delete the old container

sudo docker rm seafile

Run the new container

Go to the directory where has the docker-compose.yml file and run the following command to start the new container:

sudo docker-compose up
# You may need to install the docker-compose beforehand, plus the -d to run the command in the background.

Tip: In addition to setting the correct TIME_ZONE in the docker-compose.yml , you also need to set TIME_ZONE = 'your-timezone' in the seahub_settings.py.