0
votes

I am using postgresql on an embedded device running yocto (customized linux). The package containing postgresql does not provide psql or pg_restore. /usr/bin provides the following tools:

enter image description here

pg_basebackup indicates that I am able to create backups. But how am I supposed to restore a backup within a terminal? With pg_restore or psql this would not be a problem for me.

Please note: I want to use a backup created on my windows/linux computer to create the initial database on the embedded device.

1
psql and pg_restore are client side tools. You don't need them on the server to restore a backup. If you can connect from your desktop to the Postgres server running on your device, you can restore the dump from your Windows/Linux computer. pg_basebackup is mainly used to bootstrap a second node for replication. There is no equivalent "restore tool for that because it simply creates a copy of the data directory. - a_horse_with_no_name
It would be possible to restore a backup via network. However, I want to initialize the embedded system with the first boot providing all necessary files (such as the current database backup). Therefore I need some advice how to restore a backup directly on the server if the backup files are available on the system. - Anonymous
You can initialize the database over the network, then shutdown Postgres on the device and copy the data directory - a_horse_with_no_name
This is no option since I do not want to do this each time manually. I simply want to provide the latest backup files to the server image (currently *.sql) and restore them with the first system boot... It would already be sufficient to run simple *.sql-scripts from the command line, but how can i do that without psql? - Anonymous
Maybe you can install a "postgres-client" package that includes psql from the place where you downloaded the server software? - a_horse_with_no_name

1 Answers

1
votes

Create backup of the db using command:

pg_basebackup -h {host_ip} -D pg_backup  -U {USER}

for restoring just change the data folder to pg_backup. Now start the psql server.