---
url: https://flip-chart.ru/developers/en/on-premise/other/dump-database.md
description: >-
  Create and restore a PostgreSQL database dump of flip on-premise with pg_dump
  and pg_restore: commands for a Standalone installation, backup notes and
  version requirements.
---

# Database dump

The utilities are described in the [PostgreSQL 15](https://www.postgresql.org/docs/15/index.html) documentation. The commands below are for a Standalone installation (PostgreSQL in the `flip-postgres` container). In an HA installation, run `pg_dump`/`pg_restore` directly on the PostgreSQL server.

## Creating a dump

Run the commands from the `deploy/docker-compose` directory; the credentials are taken from the container's environment variables.

```bash
docker compose exec flip-postgres sh -c 'PGPASSWORD="$POSTGRES_PASSWORD" pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" -F c -f /backup.dump'
docker compose cp flip-postgres:/backup.dump ./backup.dump
```

The result is a `backup.dump` file in the current directory.

::: tip Backups
A database dump does not include the files in S3 storage. A full backup of a Standalone installation means archiving the PostgreSQL, Valkey and MinIO volumes as described in the [migration guide](/en/on-premise/other/migrate-flip-chart).
:::

## Restoring from a dump

1. Stop the application services:
   ```bash
   docker compose stop flip-backend flip-mcp-server flip-file-handlers
   ```
2. Copy the dump into the container and restore the database:
   ```bash
   docker compose cp ./backup.dump flip-postgres:/backup.dump
   docker compose exec flip-postgres sh -c 'PGPASSWORD="$POSTGRES_PASSWORD" pg_restore -U "$POSTGRES_USER" -d "$POSTGRES_DB" --clean --if-exists /backup.dump'
   ```
3. Start the application:
   ```bash
   docker compose up -d
   ```

::: danger Versions
A dump is restored to the same application version it was created on.
:::
