I try to restore only one table from the Postgres full backup file (.backup). Here is the command line:
/usr/lib/postgresql/9.4/bin/pg_restore --host 'localhost' --port 5432 --schema="schema1" --table="table1" --username "postgres" --dbname "DB4TEST" --no-password --verbose "/path/to/fullDB.backup"
But I get this error:
Segmentation fault(core dumped)
Can anyone tell me where I went wrong?
Related
I've extracted a pg_dump, but I'm not 100% sure on what I should name my output file. Here is my command:
pg_dump --dbname=db --format=t --host=foo --username=db --password=bar --dbname=db --exclude-table=store > db_backup
This gets my a nice file, 120megs, as I'd expect. When I try to do pg_restore in PG admin, I get:
pg_restore: error: input file does not appear to be a valid archive
The command pgdmin is running is like this:
pg_restore.exe --host "localhost" --port "5432" --username "foo" --no-password --role "yanis" --dbname "air" --verbose
Please make sure that in pgadmin restore window you are passing the full path including the file name. Pgdmin will create a command something like this:
pg_restore.exe --host "localhost" --port "5432" --username "foo" --no-password --role "yanis" --dbname "air" --verbose "C:/db_backup"
Also, make sure that pgadmin can read db_backup file and the permission on file is not restricted.
I have a .backup file in D:\test; I need to restore this backup using commandline. I used below command. but it is not working;
psql.exe -U username -d dbname -f "d:\backup\myfile.backup"
also I used below too
psql -h hostname -U username -d databasename -f "D:\backup\myfil.backup"
I guess, you are using Postgresql under Windows.
Then you have to switch to the directory where your pg_restore.exe lies.
e.g. create a batch file:
set DBname=myDatabaseName
set filename=myfile.backup
cd PostgreSQL\9.5\bin\
pg_restore.exe --host localhost --port 5432 --username "postgres" --dbname "%DBname%" --verbose "F:\Backup_DB\%filename%"
I have error like at the picture when I dump the data. I change ssl_renegotiation_limit=0 but I have same error. I have error
pg_dump: Dumping the contents of table "tunggakan" Failed: PQgetCopyData failed.
pg_dump: The command was : COPY public.tunggakan(blabla,blaaa,blabla) to stdout; "
I use the following syntax:
pg_dump --host localhost --port 5432 --username "postgres" --format custom --blobs --verbose --file "/root/thecontent.backup" "table name"
I downloaded the xbrldb_SEC_pg_2014-11-02.pg.gzip postgres pg_dump file from arelle.org. I then ran the schema ddl file in pgAdminIII and it recreated all of the databases, functions, etc.
When I try to restore the databases using the following:
desktop:~/Downloads$ sudo postgres zcat xbrldb_SEC_pg_2014-11-02.pg.gzip | psql -U postgres public
I get:
sudo: postgres: command not found psql: FATAL: Peer authentication failed for user "postgres"
I can zcat the file into a file to expand it. Looks like it is a pg_dump file.
postgres=> pg_restore -a /home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-02.txt
postgres-> ;
ERROR: syntax error at or near "pg_restore"
LINE 1: pg_restore -a /home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-0...
^
postgres=> pg_restore -a postgres /home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-02.txt;
ERROR: syntax error at or near "pg_restore"
LINE 1: pg_restore -a postgres /home/jeremy/Downloads/xbrldb_SEC_pg_...
So then I tried to use PG Admin III, and my output:
/usr/bin/pg_restore --host localhost --port 5432 --username "postgres" --dbname "public" --role "postgres" --no-password --section data --data-only --exit-on-error --table accession --schema public --verbose "/home/jeremy/Downloads/xbrldb_SEC_pg_2014-11-02.backup"
pg_restore: [archiver] input file appears to be a text format dump. Please use psql.
Process returned exit code 1.
May I please ask what I need to do to get the databases restored?
Does anyone know what I need to do to get the database updated from 2014-11-02 to the current date?
You should run psql as postgres user, not zcat, so try to use following:
zcat xbrldb_SEC_pg_2014-11-02.pg.gzip | sudo -u postgres psql public
PS pg_restore is an utility, not a PostgreSQL command, that means you should run it from command line, not from psql.
I am dumping my database 'mydatabase' into a text file 'mydatabase.sql' through command line.
"C:/Program Files (x86)/PostgreSQL/9.1/bin/pg_dump.exe " --host localhost --port 5432 --username "postgres" --no-password --verbose --file "C:\Users\User 1\Desktop\mydatabase.sql" "mydatabase"
Thas' going nice.
But after many tries I can't do a pg_restore those file back to database with data.
But if I delete all tables in this database I can do it with:
psql -f "C:\Users\User 1\Desktop\mydatabase.sql" "mydatabase" "postgres"
This recover's all data.
Problem is that I can't run pgsl through VBNET/shell so I would rather need pg_restore.exe
This is my try:
"C:/Program Files (x86)/PostgreSQL/9.1/bin/pg_restore.exe " -i -h localhost -p 5432 -U postgres -d "mydatabase" -v "C:\Users\User 1\Desktop\mydatabase.sql"
...where I get message:
C:\Users\User 1>"C:/Program Files (x86)/PostgreSQL/9.1/bin/pg_restore.exe " -i -h
localhost -p 5432 -U postgres -d "mydatabase" -v "C:\Users\User 1\Desktop\mydatabase.sql"
invalid binary "C:/Program Files (x86)/PostgreSQL/9.1/bin/pg_restore.exe "
pg_restore.exe : [archiver] input file does not appear to be a valid archive
Before trying to restore I have empty database 'mydatabase' on server (without tables).
Please any help to get pg_restore working with 'mydatabase.sql' which is dumped with pg_dump and which obviously contains a proper data so I can use it through pure command line or VBNET/shell.
In your pg_dump, specify the -F t flag. This tells pg_dump to create the backup in tar format, which is suitable for restore via pg_restore.
"C:/Program Files (x86)/PostgreSQL/9.1/bin/pg_dump.exe " --host localhost --port 5432 --username "postgres" --no-password --verbose -F t --file "C:\Users\User 1\Desktop\mydatabase.sql" "mydatabase"