Claus-Theodor Riegg
6 years
Andreas Vöst
1 year

Barman recovery fails with missing history file

Updated . Posted . Visible to the public. Repeats.

When restoring a barman PITR backup you may encounter this error:

Copying required WAL segments.
EXCEPTION: {'ret': 2, 'err': '/bin/sh: 1: cannot open /var/lib/barman/foopostgres/wals/00000007.history: No such file\n', 'out': ''}

The reason is that the barman backups xlog.db file contains a history file which is no longer present in the wals directory of your backup. The most likely reason is that someone deleted this file in the past. If you do not need this file for restoring your current backup (maybe because it's very old and you try to restore a recent backup) you can rebuild your xlog.db file.

recommendation: never delete the history files in your barman backup directories. Even though you (think) that you will not need them anymore. This will prevent issues like this.

Before you rebuild you xlog.db file you should create a backup:

cp /var/lib/barman/foopostgres/wals/xlog.db /var/lib/barman/foopostgres_xlog.db_bck

Afterwards you can rebuild your xlog.db and you recovery should work: \

barman rebuild-xlogdb foopostgres

What is the xlog.db file?

The file contains metadata about your wal archive on the barman server. It's updated when new WAL data arrives or when barman deletes outdated WAL data. If you delete files manually you will encounter problems when trying to restore a backup.

Claus-Theodor Riegg
Last edit
Moritz Kraus
License
Source code in this card is licensed under the MIT License.