On Mon, Nov 28, 2016 at 11:20 PM, Thomas Kellerer <spam_eater@xxxxxxx> wrote:
Israel Brewster schrieb am 28.11.2016 um 23:50:
pg_archivecleanup -n /mnt/server/archiverdir 000000010000000000000010.00000020.backup
Ok, but where does that "000000010000000000000010.00000020.backup"
come from? I mean, I can tell it's a WAL segment file name (plus a
backup label), but I don't have anything like that in my WAL
archives, even though I've run pg_basebackup a couple of times. Do I
have to call something to create that file? Some flag to
pg_basebackup? At the moment I am running pg_basebackup such that it
generates gziped tar files, if that makes a difference.
The .backup file will be inside the tar file if I'm not mistaken
I don't think it will be, but there will be a backup_label file in there, which contains much of the same contents as the .backup file does. But in this case, the contents of the file are not important, only the name is. pg_archivecleanup doesn't attempt to open the file-name given as the second argument, it just looks at the name itself. So you could pull backup_label out of the tar file, parse the contents and use them to construct the command to give to pg_archivecleanup.
I think it would really be nice if pg_basebackup -D backup_dir -Ft would create the backup_label file not only in the tarball, but also (as the final step) create it as a loosie file in the backup_dir.
Cheers,
Jeff