Skip to main content

Migration of PostgreSQL databases to Managed Databases for 1C

You can migrate data from your PostgreSQL database to Selectel Managed Databases using a logical dump.

Before migrating, create a target database cluster. The versions of the target and source clusters must match.

Logical dump

Create a database dump (a file containing restoration commands) in the source cluster and restore the dump in the destination cluster.

You can create an SQL dump of all databases (name, tables, indexes, and foreign keys will be preserved) or a custom format dump (for example, you can restore only the schema or data of a specific table).

SQL dump

  1. Create a database dump in the source cluster using the pg_dump utility:

    pg_dump \
    -h <host> \
    -U <user_name> \
    -d <database_name> \
    -f dump.sql

    Specify:

    • <host> — IP address or DNS name of the master host of the source cluster;
    • <user_name> — username;
    • <database_name> — database name.
  2. Restore the dump in the target cluster using the psql utility:

    psql \
    -f dump.sql \
    -h <host> \
    -p 5432 \
    -U <user_name> \
    -d <database_name>

    Specify:

    • <host> — IP address or DNS name of the master host of the target cluster;
    • <user_name> — database username;
    • <database_name> — database name.

Custom format dump

A database copy in custom format is compressed by default.

  1. Create a database dump in the source cluster using the pg_dump utility:

    pg_dump \
    -Fc -v \
    -h <host> \
    -U <user_name> \
    <database_name> > archive.dump

    Specify:

    • <host> — IP address or DNS name of the master host of the source cluster;
    • <user_name> — database username;
    • <database_name> — database name.
  2. Restore the dump in the target cluster using the pg_restore utility:

    pg_restore \
    -v \
    -h <host> \
    -U <user_name> \
    -d <database_name> archive.dump

    Specify:

    • <host> — IP address or DNS name of the master host of the target cluster;
    • <user_name> — database username;
    • <database_name> — database name.