Skip to content

Migrating from Docker

dionysius edited this page Oct 4, 2026 · 4 revisions

Moving an existing deployment from the official docker images to this package. The data formats are identical: the object store, the current_version stamp, seahub-data and the three databases carry over unchanged - only the locations and the configuration mechanism differ.

Before You Start

  • The package version must be the same as or newer than the docker version - check cat /opt/seafile-data/seafile/seafile-data/current_version against apt-cache policy seafile-server. seafile-migrate refuses to run data stamped with a newer version than the installed schema; it upgrades older data automatically.
  • Paths below assume docker's defaults (/opt/seafile-data for SEAFILE_VOLUME); adjust to your .env.

Export From Docker

Stop the application container so the databases and the object store are consistent (the database container keeps running for the dump):

cd /opt/seafile
docker compose stop seafile
mkdir ~/seafile-export && cd ~/seafile-export
docker exec seafile-mysql mariadb-dump -uroot -p'<INIT_SEAFILE_MYSQL_ROOT_PASSWORD from .env>' --databases ccnet_db seafile_db seahub_db > databases.sql
tar -C /opt/seafile-data/seafile -czf data.tar.gz seafile-data seahub-data/avatars seahub-data/custom
grep -E '^(JWT_PRIVATE_KEY|SEAFILE_SERVER_PROTOCOL|SEAFILE_SERVER_HOSTNAME)=' /opt/seafile/.env > settings.txt
grep '^SECRET_KEY' /opt/seafile-data/seafile/conf/seahub_settings.py >> settings.txt
cp /opt/seafile-data/seafile/conf/seafile.conf /opt/seafile-data/seafile/conf/seahub_settings.py .

seahub-data/thumbnail is a cache and regenerates on demand; leave it behind. Database names other than the defaults need the same names in seafile.env later.

Import Into the Package

Install the package and MariaDB as in Installation, then create the database user and import the dump - it creates the three databases itself:

sudo mysql <<'SQL'
CREATE USER 'seafile'@'127.0.0.1' IDENTIFIED BY 'choose-a-strong-password';
GRANT ALL PRIVILEGES ON ccnet_db.* TO 'seafile'@'127.0.0.1';
GRANT ALL PRIVILEGES ON seafile_db.* TO 'seafile'@'127.0.0.1';
GRANT ALL PRIVILEGES ON seahub_db.* TO 'seafile'@'127.0.0.1';
FLUSH PRIVILEGES;
SQL
sudo mysql < databases.sql

Configure as in Configuration, but with the values from settings.txt instead of new ones - JWT_PRIVATE_KEY, SEAFILE_SERVER_PROTOCOL and SEAFILE_SERVER_HOSTNAME into seafile.env, SECRET_KEY into seahub_settings.py. Reusing SECRET_KEY keeps existing sessions and tokens valid. Carry over any option you had added to docker's seafile.conf/seahub_settings.py into the package's files; don't replace them wholesale, they are structured differently (seafile.conf's [database] block in particular must stay).

Put the data in place (the state directory doesn't exist before the first start):

sudo install -d -o seafile -g seafile -m 0750 /var/lib/seafile
sudo tar -C /var/lib/seafile -xzf data.tar.gz
sudo chown -R seafile:seafile /var/lib/seafile/seafile-data /var/lib/seafile/seahub-data
sudo chmod -R u+rwX,g+rX,o-rwx /var/lib/seafile/seafile-data /var/lib/seafile/seahub-data

Start the services:

sudo systemctl start seafile.target

seafile-migrate reads the current_version stamp that came with the data: same version as the package - nothing to do; older - the schema upgrades run, exactly as they would on a package upgrade. Point the reverse proxy at the new host as described in Configuration, then log in with your existing accounts.

Verify

  • Accounts and libraries are listed as before, files download with their original content.
  • Avatars and a custom logo show up (served from seahub-data).
  • Thumbnails appear again on first view (regenerated into /var/cache/seafile).

Clone this wiki locally