Migrating Data into Catena
Moving Catena from one server to another
This instruction applies to the situation when you did configure Catena and need to migrate it on a new server without losing the configuration.
To export Catena's data, run the following commands:
su - postgres
pg_dumpall > catena.out
Copy the file catena.out
into a new instance and use the command to run the import process:
su - postgres
psql -f catena.out postgres
Copy from the old server the /etc/catena/config.json
file and replace it on the new server.
To get the new password for admin@example.com, run the following command:
/opt/catena/bin/setup reset_admin
Restart Catena:
service catena restart
Importing the configuration into Catena on the same server with XC
This instruction applies to the situation when you installed Catena on the same server with the database you want to migrate into Catena.
To start import from MySQL database, run the following command:
/etc/init.d/catena import mysql://root:password@localhost/xc
Here root:password
is MySQL username and password, xc
is a database name.
Importing the configuration into Catena from an external server with XC
This instruction applies to the situation when you have installed Catena on a new server, and want to migrate the database from another sever.
Create a tunnel to the remote server:
ssh root@remote-server.example -L 3307:127.0.0.1:3306
Here:
root@remote-server.example
is the user name and host name of the sever from where we will migrate the database.3307:127.0.0.1:3306
islocalport:localhost:destination port
(MySQL works on port 3306).
After the tunnel is established, open a new SSH connection to the server where Catena was installed, and run the migration command:
/etc/init.d/catena import mysql://root:password@localhost:3307/xc
Here:
root:password
— MySQL username and password.xc
— a database name.
Importing the configuration into Catena from an SQL backup file
This instruction applies to the situation when you have an SQL backup file.
Install MySQL server on the machine where Catena was installed:
apt update
apt -y install mysql-server
Create an empty MySQL database:
mysql -u root -p
CREATE DATABASE database_name;
Copy your SQL backup file on the server, for example, in the /tmp
directory. So the path to your file is /tmp/dump.sql
.
Import the backup file into MySQL:
mysql -u root -p database_name < /tmp/dump.sql
After importing data to a local MySQL database, you can import your database in Catena. To import from MySQL database to Catena, run the following command:
/etc/init.d/catena import mysql://root:password@localhost/xc
Here root:password
is MySQL username and password, xc
is a database name.
If you enter correct credentials, you'll see a hundred or thousand green log messages, and the import will finish in about 10-120 seconds depending on your database size.
Make sure that you enter a valid username, password, and database, and do not try to import the database twice to avoid data corruption.