Import Database and Media Dump
This article is structured for an export from EMS, but may also be applicable in other circumstances.
For support on Synapse or matrix-media-repo, ask in the Matrix rooms #synapse:matrix.org and #mediarepo:t2bot.io
Prerequisites
You need these items to complete the import. If you are migrating from EMS, EMS support will provide all five to you
- Database dump
- Media export
- GPG decryption password
- Pepper
- Synapse signing key
Import process
-
Following official documentation, install and configure
-
When generating your Synapse configuration file, you MUST use the same domain as your EMS server.
-
Do not start Synapse yet.
-
In the Synapse config file (usually
homeserver.yaml
), set:- pepper to the value received. If you do not to this you have to reset all passwords.
- Signing key. This is stored in a file. See this config file option for path. Alternatively, add the old key to old_signing_keys.
-
Download the database and media exports provided.
-
Decrypt and extract the exports
gpg --no-symkey-cache --output postgres-export.sql.gz --decrypt postgres-export.sql.gz.gpg gpg --no-symkey-cache --output export-part-1.tgz --decrypt export-part-1.tgz.gpg gzip --decompress postgres-export.sql.gz tar zxvf export-part-1.tgz
-
Import the database dump
-
If your Synapse database is not empty, empty it
WARNING - THIS WILL IMMEDIATELY AND IRRECOVERABLY DELETE DATA. WE TAKE NO RESPONSIBILITY IF YOU DELETE THE WRONG DATABASE OR THE WRONG DATAConnect to the database with
psql
, then run the following queries:DO $$ DECLARE r RECORD; BEGIN FOR r IN (SELECT tablename FROM pg_tables WHERE schemaname = current_schema()) LOOP EXECUTE 'DROP TABLE ' || quote_ident(r.tablename) || ' CASCADE'; END LOOP; END $$; DROP sequence cache_invalidation_stream_seq; DROP sequence state_group_id_seq; DROP sequence user_id_seq;
-
Disconnect from the database, then import the database dump
psql --username=USERNAME --host=HOSTNAME DATABASE_NAME < postgres-export.sql
-
Verify that sequence was set correctly. Connect to the database and run the query
SELECT * FROM state_group_id_seq;
last_value
should be greater than 1
-
-
Import media according to documentation here.
-
Start Synapse.
-
Optionally, install Element Web or use another Matrix client.