title: Couldn't restore postgres v11 from pg_basebackup
body: <p>I'm making a backup from my postgresql database (v11) using <code>pg_basebackup</code> like this:</p>
  
  <pre class="lang-sh prettyprint-override"><code>pg_basebackup -h localhost -p 5432 -U postgres -D /tmp/backup -Ft -z -Xs -P
  </code></pre>
  
  <p>The backup process is completed just fine without any errors.Then as a test I'd like to recover from the backup and for that I do the following steps:</p>
  
  <ol>
  <li>Shutdown the postgres instance.</li>
  <li><p>Delete everything from <code>/var/lib/postgresql/data</code> folder</p>
  
  <p><code>rm -rf /var/lib/postgresl/data/*</code></p></li>
  <li><p>Untar the base archive there:</p>
  
  <p><code>tar xvf /tmp/backup/base.tar.gz -C /var/lib/postgresql/data</code></p></li>
  <li><p>Untar the wal archives to a temporary directory </p>
  
  <p><code>tar xvf /tmp/backup/pg_wal.tar.gz -C /tmp/archived_wals</code></p></li>
  <li><p>Create a file <code>recovery.conf</code> in the <code>/var/lib/postgresql/data</code> folder:</p>
  
  <pre><code>touch /var/lib/postgresql/data/recovery.conf
  chown postgres:postgres /var/lib/postgresql/data/recovery.conf
  </code></pre></li>
  <li><p>Specify the recovery command in the recovery.conf file:</p>
  
  <p><code>restore_command = 'cp /path/archived_wals/%f "%p" '</code></p></li>
  <li><p>Restart the postgres instance, and wait for the recovery to be finished.</p></li>
  </ol>
  
  <p>However when postgres starts up I get the following error in the logs:</p>
  
  <pre class="lang-sh prettyprint-override"><code>2020-02-04 11:34:52.599 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
  2020-02-04 11:34:52.599 UTC [1] LOG:  listening on IPv6 address "::", port 5432
  2020-02-04 11:34:52.613 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
  2020-02-04 11:34:52.709 UTC [18] LOG:  database system was interrupted; last known up at 2020-02-04 08:39:54 UTC
  cp: can't stat '/tmp/archived_wals/00000002.history': No such file or directory
  2020-02-04 11:34:52.735 UTC [18] LOG:  starting archive recovery
  2020-02-04 11:34:52.752 UTC [18] LOG:  invalid checkpoint record
  2020-02-04 11:34:52.752 UTC [18] FATAL:  could not locate required checkpoint record
  2020-02-04 11:34:52.752 UTC [18] HINT:  If you are not restoring from a backup, try removing the file "/var/lib/postgresql/data/backup_label".
  2020-02-04 11:34:52.753 UTC [1] LOG:  startup process (PID 18) exited with exit code 1
  2020-02-04 11:34:52.753 UTC [1] LOG:  aborting startup due to startup process failure
  2020-02-04 11:34:52.769 UTC [1] LOG:  database system is shut down
  </code></pre>
  
  <p>I guess I'm missing something, maybe I need to do additional configuration to postgres to be able to restore a <code>pg_basebackup</code> backup?</p>