> For the complete documentation index, see [llms.txt](https://dev-notes.vinguyen.blog/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev-notes.vinguyen.blog/notes/deployment-and-operation/database/postgresql/backup-and-import-single-database-postgresql-inside-docker-container.md).

# Backup & Import single database PostgreSQL Inside Docker Container

#### Backup

```bash
docker exec -t your_db_container_name pg_dump -c -U your_db_username your_database > dump_$(date +%Y-%m-%d_%H_%M_%S).sql
```

#### Restore

```bash
cat your_dump.sql | docker exec -i your_db_container_name psql -U your_db_username -d your-db-name
```
