Backup and Recovery: Single-Server Streaming - Recovery
Suggest editsIn the previous step, we created a full backup of the example database. But it's not a real backup until we've successfully restored it - so let's end with that.
This demo is interactive
You can follow along right in your browser. When you click "Start Now," Katacoda will load a Docker Compose
environment with two container images representing a PostgreSQL 13 server with
the Pagila database loaded (named pg
)
and a backup server for Barman (named backup
).
Once you see a barman@backup
prompt, you can follow the steps below.
Something terrible has happened to our example database! This should list all the tables:
All the data is gone!
Ok, I just didn't populate the data for this step, in order to demonstrate a total loss. Fortunately, we still have a backup!
Let's instruct Barman to ssh into the database server and restore the backup.
Connect to pg and shut down the database cluster:
Back up the corrupt data directory, just in case something goes wrong. Then delete the corrupt data.
Use Barman's recover command to connect to pg and restore the latest backup
Barman handles connecting to the destination server, but we do have to provide a valid path on that server. In this example, the PostgreSQL cluster lives in /var/lib/postgresql/data and we're asking Barman to overwrite it with the backup.
Restart the server:
Now we should be able to reconnect to the database: