# Backup and restore a PostgreSQL container data.
If you're using a PostgreSQL container and mounting its data as volume (for persistence), here is ho you can extract it to an archive (and then restore it). Let's say you have a PostgreSQL container called `project-pythia-db-1`.
### PostgreSQL volume to archive on local disk.
```
# Zip the data to an archive inside the container
docker exec project-pythia-db-1 tar cvf /var/lib/postgresql/data/pgdata_backup.tar /var/lib/postgresql/data
# Copy the archive to local disk
docker cp project-pythia-db-1:/var/lib/postgresql/data/pgdata_backup.tar $pwd/backup/pgdata_backup.tar
```
### Restore a local disk archive to PostgreSQL volume
```
# Upload and unzip the PostgreSQL archive to the container volume.
docker run --rm -v project-pythia_pgdata:/var/lib/postgresql/data -v $pwd/backup:/backup ubuntu bash -c "tar xvf /backup/pgdata_backup.tar -C /"
```
This is useful to share a dev database state when working with co-workers on a project!