I'm trying to import osm data using osm2pgsql onto an aws rds instance. I get an error saying Osm2pgsql failed due to ERROR: Open failed for 'insights_poi': No such file or directory but I am providing all the necessary files.
Locally, I'm running osm2pgsql -c -d insights_poi -U insights_poi -H beta.cyrrprcqeykj.us-east-1.rds.amazonaws.com -S default.style austin_texas.osm.pbf -W insights_poi -r .pbf
and the default.style and the austin_texas.osm.pbf file are in the same folder I'm running this from. Why is it saying it can't find the file?
It actually gets pretty far after I run the command
For the -W, the docs specified -w forces password prompt which I treated as a parameter. so The error Osm2pgsql failed due to ERROR: Open failed for 'insights_poi': No such file or directory was a result of -W insights_poi since nothing was really expected after the -W, it was treating the insights_poi value as the name of a file there that didn't exist.
In the end this did it, osm2pgsql -c -d insights_poi -U insights_poi -H beta.cyrrprcqeykj.us-east-1.rds.amazonaws.com -r .pbf -S default.style -W austin_texas.osm.pbf
Related
I took a postgresql DB Bacup with the below command
pg_dump -Z6 -h localhost test_db -f test_db.tar -p port
Now If I try to restore it with psql facinf the below error:
psql:test_db.sql:117359: error: invalid command \gg<CB>t<E4>Iƣ<AC>=<AF>*ESC^TDuV^P^Ov<B6><B0>
psql:test_db.sql:117362: error: invalid command \a>#
psql:test_db.sql:117363: error: invalid command \"<99>k<86>
psql:test_db.sql:117372: error: invalid command \<9B>遥<FD><FE><BA>j
psql:test_db.sql:117406: ERROR: invalid byte sequence for encoding "UTF8": 0x8a
With pg_restore:
pg_restore: error: input file does not appear to be a valid archive
I thought i was using -Fc with pg_dump, but somehow I missed it. Now Can you help me to restore this Backup to postgresql.
I'm Using PostgreSQL 14.5
I've tried below commands
cat test_db.tar | psql test_db -U postgres -h localhost -p port
\i testdb.tar
even Tried to rename the dump file from test_db.tar to test_db.dump and tried restoring it. Nothing is working.
It seems -Z6 generates a gzipped file.
You can convert that into a plain text SQL script that psql can read using. To unzip it using gzip you will need to rename it, e.g. to test_db.sql.gz
Then you can use:
gzip -k -d test_db.sql.gz
-k will keep the original file
I have a Postgesql database that I want to copy/replicate from my local machine to an AWS RDS instance.
I've created a dump as follows:
pg_dump -v -U postgres mydb > mydb.dump
I then tried to copy to my RDS as follows:
psql -f mydb.dump -h XXXXXXXXXXXX.us-east-1.rds.amazonaws.com -p 5432 -U postgres -d mydb
However, I get the following error:
psql:mydb.dump:1: error: invalid command \
psql:mydb.dump:6: ERROR: syntax error at or near "ÿ_"
LINE 1: ÿ_-"\o""edrp\nou"tnsctme e
^
I then tried to rule out any issues with RDS by copying the archive to another local database as follows:
pg_restore -U postgres -d mydbcopy mydb.dump
I received an error:
pg_restore: error: input file does not appear to be a valid archive
I also tried the preceding as follows:
psql -f my.dump -U postgres -d mydbcopy
And got the same error as before:
psql:mydb.dump:1: error: invalid command \
psql:mydb.dump:6: ERROR: syntax error at or near "ÿ_"
LINE 1: ÿ_-"\o""edrp\nou"tnsctme e
^
I am using Windows Powershell and Postgresql 13.2.
Am I missing something ?
It seems to be an issue with PSQL tools in view that I'm getting the error even when trying to copy locally.
I managed to solve this problem by using
pg_dump -f dump.sql --inserts mydb
It turns out using the redirect ">" means PowerShell does the file writing and it uses UTF16 which doesn't play nice with psql. The -f flag makes pg_dump do the writing itself.
I'm using the following command to backup my database (PostgreSQL 11.8):
pg_basebackup -D "C:\\temp" -F tar -X f -z -P -U myUser
And the following to restore:
I manually unpack the base.tar.gz => base.tar
pg_restore -h localhost -W -U myUser -c -C -d myDatabase -F tar -v "C:\\temp\\base.tar"
This results in the following error:
pg_restore: [tar archiver] could not find header for file "toc.dat" in tar archive
What am I doing wrong?
Also, I tried different versions of the restore (only data, etc.) but of course the missing header file issue persists.
Thanks for your help!
You cannot use pg_basebackup and pg_restore together:
pg_basebackup is a physical backup tool
pg_restore can only be used with a logical backup created by pg_dump.
There is no single PostgreSQL command to restore a backup created with pg_basebackup.
To restore a physical backup see https://www.postgresql.org/docs/12/continuous-archiving.html#BACKUP-PITR-RECOVERY
I have downloaded the dvd rental.tar file on my desktop. followed the below instructions
pwd
/Users/O2/tools/postgres
mkdir dvdrentaldb
initdb dvdrentaldb
I get the following message
initdb directory "dvdrentaldb' exists but is not empty If you want to create a new database system either remove or empty the directory or run initdb with an argument other than "dvdrentaldb"
I have downloaded the dvd rental.tar file on my desktop. followed the below instructions
pwd
/Users/O2/tools/postgres
mkdir dvdrentaldb
initdb dvdrentaldb
post this i am using the following code
pg_restore -U O2 -d dvdrentaldb dvdrental.tar
i get syntax error at or near "pg_restore"
I get the following message
initdb directory "dvdrentaldb' exists but is not empty If you want to create a new database system either remove or empty the directory or run initdb with an argument other than "dvdrentaldb"
Got this from reddit
https://www.reddit.com/r/PostgreSQL/comments/93uuhg/can_anyone_get_this_sample_database_tutorial_to/
createuser -s dvdrental
createdb dvdrental -O dvdrental
pg_restore -U dvdrental -d dvdrental ./dvdrental.tar
I'm getting this error when I restore a Postgres backup from another server:
pg_restore: [compress_io] could not uncompress data: invalid block type
I haven't found much online about what that error means. Except of this discussion.
Is it a problem with the backup file? Is it corrupted? Or is there anything that I need to do in order for the target database to read the block type?
This is part of a script running in crontab for creating the backup: ...
if /usr/pgsql-9.1/bin/pg_dump -Fc -Z 9 -U postgres $PG_DATABASE -p $PG_PORT --schema=$SCHEMA > $PG_BACKUP_FOLDER/notus_dump_$NOW-$SILO.backup 2>/tmp/pg_dump.err
... And this is the command that restores it:
/usr/pgsql-9.1/bin/pg_restore -v -U postgres -p $PG_PORT -C -e -d $PG_DATABASE -n $SCHEMA [backup file]
All variables resolve correctly. The problem is on restore, it starts restoring but it exits with the error in the title.