logo
icon

PostgreSQL

A free and open-source relational database management system emphasizing extensibility and SQL compliance.

template cover
Deployed1218 times
Publisheryuaanlin
Created2024-06-18
Services
service icon
Tags
Database

A free and open-source relational database management system that emphasizes extensibility and SQL compliance.

Configuration

It is a one-click deployment, so you rarely need to configure PostgreSQL after deployment.

You can configure PostgreSQL by editing the file /etc/postgresql/postgresql.conf with Config Editor. We have pre-configured some of the essential settings for you.

Connection

The "Instruction" section contains the root username, password, and the default database of your PostgreSQL instance. It also provides the connection string and command for you to connect from outside.

If you want to access your PostgreSQL in your other services (inter-service), you can reference the exposed variable POSTGRES_CONNECTION_STRING in your service with ${POSTGRES_CONNECTION_STRING}. For more flexible cases, you can reference these variables:

  • POSTGRES_HOST: The hostname of this PostgreSQL instance for private networking.
  • POSTGRES_PORT: The port of this PostgreSQL instance for private networking.
  • POSTGRES_DATABASE: The default database of this PostgreSQL instance.
  • POSTGRES_USERNAME: The default root username of this PostgreSQL instance.
  • POSTGRES_PASSWORD: The default root password of this PostgreSQL instance.

If your project contains multiple PostgreSQL instances, the reference variable might be unreliable (it may pick the exposed variable of another PostgreSQL instance). In this case, manually specifying the PostgreSQL instance's hostname and port is recommended.

To find your PostgreSQL instance's hostname and port for private networking, check the "Networking" tab of your PostgreSQL instance, and you will see the hostname suffixed with zeabur.internal and the port that you can use to connect to this PostgreSQL instance.

Restoring the backup

Zeabur provides the automatic backup feature for PostgreSQL. However, you need to restore the backup manually. You can restore the backup by following the steps below:

  1. Download and extract the backup file from the backup storage. You will see a data.sql file.
  2. Find the "PostgreSQL Connect Command" in the "Instructions" section of your PostgreSQL instance.
  3. Make sure you have installed PostgreSQL client tools in your machine. Then, run:
    <Your PostgreSQL Connect Command> < data.sql
    

Note that restoring the backup also replaces the existing user password. If you prefer to keep the existing user password, you should remove the CREATE ROLE and ALTER ROLE statement from the data.sql file before running the command.