Tutorial for server migration (importing MySQL/MariaDB databases and seafile-data)


#1

This tutorial is licensed under CC-BY-SA - feel free to share and modify it (but keep information free)!

:triangular_flag_on_post: This tutorial was originally written for the first Seafile forum of Seafile GmbH. Since the announcement to fork Seafile by Seafile GmbH I’ve decided to move my tutorials to the new Seafile forum of the original developers of Seafile (so this one).
This tutorial version is the maintained one.


Tutorial for importing old MySQL/MariaDB databases and old SEAFILE-DATA

(This tutorial is an add-on for Tutorial for Seafile CE + Nginx + dynamic DNS (on ARM / Cubietruck / RaspberryPi))

Here are some more information how to do the process of restoring/importing existing seafile data. Maybe some commands are redundant. This is for confirming the right settings.
Variables are marked as %%variable%%.

I. Setup a new Seafile installation manually with standard settings
II. Drop the new database tables/user

[stop your seafile server manually or with your script]#

mysql -u root -p
SHOW DATABASES;
DROP DATABASE `ccnet-db`;
DROP DATABASE `seafile-db`;
DROP DATABASE `seahub-db`;
SHOW DATABASES;
SELECT User FROM mysql.user;
DROP USER 'username'@'localhost';

III. Create new databases/user:

CREATE DATABASE `ccnet-db`;
CREATE DATABASE `seafile-db`;
CREATE DATABASE `seahub-db`;
USE ccnet-db
SHOW TABLES;
USE seafile-db
SHOW TABLES;
USE seahub-db
SHOW TABLES;
CREATE USER '%%YourMySQL-UserForSeafile%%'@'localhost' IDENTIFIED BY '%%PasswordFor%%YourMySQL-UserForSeafile%%%%';

IV. Import your intended databases

In a second Terminal:

mysql -u root -p ccnet-db < %%ccnet-db_BACKUP%%.sql
mysql -u root -p seafile-db < %%seafile-db_BACKUP%%.sql
mysql -u root -p seahub-db < %%seahub-db_BACKUP%%.sql

In your first Terminal:

USE ccnet-db
SHOW TABLES;
USE seafile-db
SHOW TABLES;
USE seahub-db
SHOW TABLES;
GRANT ALL PRIVILEGES ON `ccnet-db`.* to `%%YourMySQL-UserForSeafile%%`@localhost;
GRANT ALL PRIVILEGES ON `seafile-db`.* to `%%YourMySQL-UserForSeafile%%`@localhost;
GRANT ALL PRIVILEGES ON `seahub-db`.* to `%%YourMySQL-    UserForSeafile%%`@localhost;
FLUSH PRIVILEGES;
exit

V. Change seafile-data directory

sudo -s
su - %%YourSystemUserNameForSeafile%% -s /bin/bash
ls -la
cp %%/path/to/old-seafile-data%% %%/path/to/seafile/%%
ls -la

VI. Ensure that intended seafile-data (for example on the external drive) belongs to Seafile user (recursively)

In your second Terminal:

sudo -s
chown -R %%YourSystemUserNameForSeafile%%:%%YourSystemGroupNameForSeafileUser%% %%/path/to/seafile-data%%

In your first Terminal:

ln -s %%/path/to/seafile-data%% seafile-data
#If there is an error it maybe happened because the seafile user can not access the mother directory of seafile-data even if your seafile-user owns the seafile-data directory so CHOWN the folder which contains seafile-data to your seafile-user:
chown -R %%YourSystemUserNameForSeafile%%:%%YourSystemUserNameForSeafile%% %%/path/mother/directory/of/seafile-data%%)
ls -la

VII. Confirm that there is the right MySQL password for
    %%YourMySQL-UserForSeafile%%

Open the following .conf files and confirm that there is the new MySQL password:

seafile/conf/ccnet.conf
seafile/conf/seahub_settings.py
seafile/conf/seafile.conf

VIII. Start your Seafile server

Done!

Please:

  1. report any bugs in this thread :bangbang:
  2. report if it works and if some sentences/comments are confusing (and why). :bangbang:
  3. ask all questions in this thread and not via PM (there are no stupid questions for me) :bangbang:

Import data in a new seafile installation