---
title: "Migration of PostgreSQL databases to PostgreSQL Managed Databases for 1C"
sidebar_label: "Migration to Managed Databases"
sidebar_position: 18
description: "How to migrate a PostgreSQL database to PostgreSQL Managed Databases for 1C"
---

import Formbricks from '@theme/MDXComponents/Formbricks'

# Migration of PostgreSQL databases to Managed Databases for 1C

You can migrate data from your PostgreSQL database to [Managed Databases](https://selectel.ru/services/cloud/managed-databases/) by Selectel using a [logical dump](#logical-dump).

:::info

Before migration, [create a destination database cluster](/managed-databases/postgresql-for-1c/create-cluster.mdx). The versions of the destination and source clusters must match.

:::

## Logical dump \{#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](#sql-dump) of all databases (names, tables, indexes, and foreign keys will be preserved) or a [custom format dump](#custom-dump) (for example, you can restore only the schema or the data of a specific table).

### SQL dump \{#sql-dump}

1. Create a database dump in the source cluster using the [pg\_dump](https://www.postgresql.org/docs/current/app-pgdump.html) utility:

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

   Specify:

   * `<host>` — the IP address or DNS name of the source cluster master host;
   * `<user_name>` — the user name;
   * `<database_name>` — the database name.
2. Restore the dump in the destination cluster using the [psql](https://www.postgresql.org/docs/9.3/app-psql.html) utility:

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

   Specify:

   * `<host>` — the IP address or DNS name of the destination cluster master host;
   * `<user_name>` — the database user name;
   * `<database_name>` — the database name.

### Custom format dump \{#custom-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:

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

   Specify:

   * `<host>` — the IP address or DNS name of the source cluster master host;
   * `<user_name>` — the database user name;
   * `<database_name>` — the database name.
2. Restore the dump in the destination cluster using the [pg\_restore](https://www.postgresql.org/docs/13/app-pgrestore.html) utility:

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

   Specify:

   * `<host>` — the IP address or DNS name of the destination cluster master host;
   * `<user_name>` — the database user name;
   * `<database_name>` — the database name.

<Formbricks />
