I make backups like this:
pg_dump -a -w mydb > mydb.sql
Well, this doesn't create SQL statements, but statements like this:
COPY table1 (atr1,atr2,atr3) FROM stdin;
val1 val2 val3
val1 val2 val3
val1 val2 val3
However, when I use cat mydb.sql | psql mydb, I get a lot of errors,
because it's no real SQL in the file...
How can I restore my dump?
* Magnus Warker tat kund und zu wissen:
I make backups like this:
pg_dump -a -w mydb > mydb.sql
That’s a data only dump, i.e. you have to connect to a database contaong the empty database tables etc. of mydb.
Why do you not create a full database dump?
Well, this doesn't create SQL statements, but statements like this:
COPY table1 (atr1,atr2,atr3) FROM stdin;
val1 val2 val3
val1 val2 val3
val1 val2 val3
It’s valid SQL for a postgresql database. And as you only requested the data, you get only the data …
How can I restore my dump?Connect to a database containing the empty database schema of mydb:
$ psql -X mydb_new < mydb.sql
On 11/10/2016 03:08 PM, Harald Wenninger wrote:
It’s valid SQL for a postgresql database. And as you only requested the
data, you get only the data …
Then psql should not alert syntax errors... #-)
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 113 |
Nodes: | 8 (1 / 7) |
Uptime: | 156:11:35 |
Calls: | 2,504 |
Calls today: | 1 |
Files: | 8,703 |
Messages: | 1,929,840 |