Thread: Why clear pg_wal when recovering?

Why clear pg_wal when recovering?

From
"Mikael Sterner"
Date:
Hi!

In the guide at https://www.postgresql.org/docs/current/continuous-archiving.html#BACKUP-PITR-RECOVERY
step 5 is to remove any files present in the pg_wal directory. Is this
still the recommendation if the source of the file system restore in step 4
was a base backup generated by pg_basebackup? Because in that case, wouldn't
the files in pg_wal still be needed to recover from the basebackup state?

I guess these files that were removed would normally be restored from the
WAL archive, but if you have for some reason lost your WAL archive, or it's
not complete, wouldn't it be better if you had retained them in the restored
data directory so that you could at least reach the state at the end of your
latest base backup?

Yours,
Mikael