Restore to a new database from a backup (.tar) generated from

From: PG Doc comments form <noreply(at)postgresql(dot)org>
To: pgsql-docs(at)lists(dot)postgresql(dot)org
Cc: rhudon(at)numetrix(dot)ca
Subject: Restore to a new database from a backup (.tar) generated from
Date: 2023-11-29 22:18:20
Message-ID: 170129630093.398197.16313313018327801446@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-docs

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/15/app-pgrestore.html
Description:

After creating a new database in postgreSQL :
CREATE DATABASE x;
I dump it in a .tar file:
pg_dump -p 5433 -U postgres -W -F t x >
C:\pgBackups\x.tar
Then I restore it with the restore command:
pg_restore -p 5433 -U postgres -W -d x -C --verbose C:\pgBackups\x.tar
RESULT : pg_restore: création de DATABASE « x »
pg_restore: pendant le traitement de la
TOC (« PROCESSING TOC ») :
pg_restore: de l'entrée TOC 3315 ; 1262
29865 DATABASE x postgres
pg_restore: erreur : could not execute
query: ERREUR: la base de données « x » existe déjà
La commande était : CREATE DATABASE x
WITH TEMPLATE = template0 ENCODING = 'UTF8' LOCALE_PROVIDER = libc LOCALE =
'French_Canada.1252';
pg_restore: connexion à la nouvelle base
de données « x »
pg_restore: attention : erreurs ignorées
lors de la restauration : 1 ' PROBLEM WITH CODE PAGE
1252 and the fact that the (empty) db already exists
if I remove the database (x) from PostgreSQL (Version 15.5) DROP
DATABASE x;
and I try the same restore command:
pg_restore -p 5433 -U postgres -W -d x -C --verbose
C:\pgBackups\x.tar
RESULT : pg_restore: connexion à la base de données pour
la restauration
Mot de passe :
pg_restore: erreur : la connexion au serveur sur « localhost » (::1), port
5433 a échoué : FATAL: la base de données « x » n'existe pas ' The
problem is that the database does not exist

So, I can I create a database from scratch, in PostgreSQL, from a backup
(.tar) file generated from pg_dump ?

Responses

Browse pgsql-docs by date

  From Date Subject
Next Message Shubham Khanna 2023-11-30 04:11:51 Re: Postgres Partitions Limitations (5.11.2.3)
Previous Message Euler Taveira 2023-11-29 18:39:07 Re: An inconsistency in the documentation about full text search