Seafile Migration and Upgrade

Seafile Migration and Upgrade

IT, Others

Since the previously deployed Seafile hosts were outdated and the Seafile version was still 7.0.x, it was decided to undertake a complete migration and reconstruction upon transitioning to a server hosted by MyLoc. Below is a record of the process.

Backup Data

Since I use S3 OSS for the Seafile backend, only the Seafile database and configuration files need to be backed up. The S3 OSS part is directly synchronized to MyLoc’s MINIO using Rclone.

All Seafile configuration files are located in seafile/conf, including ccnet.conf, gunicorn.conf.py, seafdav.conf, seafevents.conf, seafile.conf, seahub_settings.py. These files contain the original database configuration information and will need to be modified later as per the new environment.

Migrating to Docker

Initialize Docker Environment

As Seafile Pro 7.0.x dependencies are over four years old and some Python dependencies have reached end-of-life, I decided to migrate all data to the Docker environment and upgrade sequentially. First, the non-Docker configuration and data need to be migrated to Docker. Fortunately, the Seafile Pro Registry offers various images starting from version 7.0. To fetch all available Docker Registry version numbers, use the following command:

~# curl -u seafile:zjkmid6rQibdZ=uJMuWS -X GET https://docker.seadrive.org/v2/seafileltd/seafile-pro-mc/tags/list

The result will be a list like the following:

{
  "name": "seafileltd/seafile-pro-mc",
  "tags": [
    "10.0-latest",
    "10.0.10",
    "10.0.10-arm",
    "10.0.11",
    "10.0.11-arm",
    "10.0.12",
    "10.0.12-arm",
    "10.0.13",
    "10.0.13-arm",
    "10.0.14",
    "10.0.14-arm",
    "10.0.15",
    "10.0.15-arm",
    "10.0.16",
    "10.0.16-arm",
    "10.0.4",
    "10.0.5",
    "10.0.6",
    "10.0.7",
    "10.0.8",
    "10.0.9",
    "10.0.9-arm",
    "11.0-latest",
    "11.0.2-testing",
    "11.0.4",
    "11.0.4-arm",
    "11.0.5",
    "11.0.5-arm",
    "11.0.6",
    "11.0.6-arm",
    "11.0.7",
    "11.0.7-arm",
    "11.0.8",
    "11.0.8-arm",
    "11.0.9",
    "11.0.9-arm",
    "7.0.13",
    "7.0.7",
    "7.1.14",
    "7.1.17",
    "7.1.22",
    "8.0.10",
    "8.0.11",
    "8.0.12",
    "8.0.14",
    "8.0.16",
    "8.0.17",
    "9.0.10",
    "9.0.11",
    "9.0.12",
    "9.0.13",
    "9.0.14",
    "9.0.15",
    "9.0.16",
    "9.0.4",
    "9.0.5",
    "9.0.6",
    "9.0.7",
    "9.0.8",
    "9.0.9",
    "latest"
  ]
}

Thus, data import begins with version 7.0.13. Official migration guides are available, but to avoid installing additional databases on the host system for easier maintenance, I transferred all services into the Docker environment using the provided docker-compose.yml.

Before starting, log in to the Docker Registry:

~# docker login docker.seadrive.org

Download the sample docker-compose.yml:

mkdir /opt/seafile
cd /opt/seafile

# Seafile PE 7.1 and 8.0
wget -O "docker-compose.yml" "https://manual.seafile.com/docker/docker-compose/pro/7.1_8.0/docker-compose.yml"

Modify the configuration file, setting the root password for MariaDB and the default user for Seafile. Create the necessary directories for data persistence:

~# mkdir /opt/seafile-data
~# mkdir /opt/seafile-mysql
~# mkdir -p /opt/seafile-elasticsearch/data
~# chmod 777 -R /opt/seafile-elasticsearch/data

Run Docker to generate the configuration files and verify service operation by accessing port 80. Once confirmed, stop Docker:

~# cd /opt/seafile-data
~# docker compose up -d
~# docker compose down # Stop after verification

Import Database

Since the database generated in the previous step will not be used in subsequent steps, it can be removed via rm -rf /opt/seafile-mysql/* or by dropping the databases. Start MySQL only:

~# docker compose up -d db

Log in with the root password predefined in docker-compose.yml and import the backup database:

~# docker exec -i seafile-mysql mysql -u root -p$Password < backup.sql

Next, log into the database to create the database user and grant permissions:

~# docker exec -it seafile-mysql mysql -u root -p # Login to modify the database
MariaDB [(none)]> CREATE USER 'seafile'@'%.%.%.%' IDENTIFIED BY 'your_password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON `ccnet`.* TO 'seafile'@'%.%.%.%';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON `seafile-db`.* TO 'seafile'@'%.%.%.%';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON `seahub-db`.* TO 'seafile'@'%.%.%.%';
MariaDB [(none)]> FLUSH PRIVILEGES;

After creation, log in as the Seafile user to verify database access.

Modify Configuration Files

Once the database import is complete, modify the Seafile configuration files to match the new database details. Amend ccnet.conf, seafevents.conf, seafile.conf, seahub_settings.py by updating the database names, user names, and passwords. In my configuration, the S3 OSS backend and memcached also required configuration according to the new environment. Generally, once the configuration files are adjusted to correspond with the database settings, Seafile should operate correctly.

If the S3 environment uses a self-signed certificate, the configuration files must be amended to include the CA certificate. The straightforward approach is to add the CA to the host system, verify its inclusion with tools like CURL, and then mount /etc/ssl/certs in read-only mode within the Seafile container by modifying the volumes:

volumes:
- /opt/seafile-data:/shared # Required for Seafile data persistence.
- /etc/ssl/certs:/etc/ssl/certs:ro # Server certificates

Then start Docker:

~# docker compose up -d

At this point, the migration is complete, and Seafile can typically be accessed via a browser. If necessary, modify the reverse proxy by editing /opt/seafile-data/nginx/conf/seafile.nginx.conf to suit the new environment.

Upgrading Seafile

The benefits of Docker become more apparent during this step. By adjusting the Docker image version and adapting the compose configuration, you can upgrade Seafile versions. The upgrade path outlined in the official documentation should be followed, upgrading sequentially from: 7.0 -> 7.1 -> 8.0 -> 9.0 -> 10.0 -> 11.0, using the last patch release of each Major version.

The 7.0 to 8.0 upgrade requires no changes to docker-compose.yml. Successful web access to Seafile marks the upgrade completion.

For the 8.0 to 9.0 upgrade, update dependencies:

  • Upgrade MariaDB to 10.6 and add the environment variable MARIADB_AUTO_UPGRADE=1;
  • Upgrade memcached to 1.6.18;
  • Switch to the official Elasticsearch image 7.16.2;

For the 9.0 to 10.0 upgrade, update dependencies:

  • Upgrade MariaDB to 10.11;
  • Sequentially upgrade Elasticsearch to 7.17.5 and 8.6.2, adding the environment variable "xpack.security.enabled=false". Directly upgrading to 8.6.2 may encounter "log.level": "ERROR", "message": "fatal exception while booting Elasticsearch", "ecs.version": "1.2.0", "service.name": "ES_ECS" ….

Upgrading to the latest v11 requires no additional configuration changes.

References:
https://manual.seafile.com/docker/non_docker_to_docker/

https://manual.seafile.com/upgrade/upgrade_docker/

https://manual.seafile.com/docker/pro-edition/deploy_seafile_pro_with_docker/

https://bbs.seafile.com/t/topic/19304

Amefs, EFS, Linux
Previous Post
Configure AdGuardHome on pfSense

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

keyboard_arrow_up