Backup and Recovery: Single-Server Streaming - Running a Base Backup
With the Barman server configured in our last step, we can run a full backup (or "base backup").
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.
To run a full backup, we use Barman's backup
command:
The --wait
option causes Barman to wait for arrival and processing of the WAL file corresponding to the end of the backup, to ensure the backup is complete before the command returns.
Note
Since the cron job is doing this periodically in the background, the WAL segments you see listed may be different than the output listed above!
Verify that it completed by listing backups for the server:
(the timestamps will be different for you)
Of course, we've configured streaming backups - so we shouldn't need to depend on having a base backup for every change made to the database. Let's make a small modification to the data and verify that it arrives.
First, log into the database (we'll use our barman user for convenience in this demonstration):
Then make a modifications, and view the results:
Ok, let's see if it showed up:
There it is! The current WAL segment hasn't been rotated yet, but we have the most recent data in the partial WAL streamed to Barman. So in theory, nothing would be lost if something terrible happened to the database right now...
Now, the crucial question with backups is always the same: "can you get the data back?"
We'll answer this in Step #4: Restoring a Backup.
Could this page be better? Report a problem or suggest an addition!