Allow PostgreSQL remote connection

Permit BackupSheep to access and interact with your PostgreSQL database.

To allow a remote connection to a PostgreSQL database, you must adjust some configuration settings in PostgreSQL and potentially in your operating system. Here are the steps:

1. Update PostgreSQL.conf:

This file is usually located in the PostgreSQL data directory. The location of this directory depends on your operating system and your PostgreSQL installation.

On a Unix-like system, a common location is /var/lib/pgsql/data/postgresql.conf, but it could also be in /etc/postgresql/[version]/main/postgresql.conf on Ubuntu.

You can also determine the location of this file by connecting to PostgreSQL and running SHOW config_file;

In this file, find the line that starts with #listen_addresses = 'localhost'

Remove the # to uncomment the line and change localhost to * (which means listen on all IP addresses). The line should look like this:

listen_addresses = '*'

This allows PostgreSQL to listen on all network interfaces.

2. Update pg_hba.conf:

The pg_hba.conf file is also located in the data directory. In this file, you need to specify which hosts are allowed to connect. Add a line like this to the end of the file:

host    all             all                  md5

This line allows all users from any host to connect to all databases if they know the password. If you want to restrict access, you can replace all and with the specific usernames and IP addresses you want to allow.

Note: If you want to allow IPv6 connections as well, you should also add:

host    all             all             ::/0                    md5

3. Restart PostgreSQL:

The changes won't take effect until you restart PostgreSQL. On a Unix-like system, you can usually do this with a command like sudo service postgresql restart or sudo systemctl restart postgresql

4. Configure your firewall:

If you have a firewall enabled on the machine running PostgreSQL (like iptables on Linux or Windows Firewall on Windows), you might need to adjust its settings to allow incoming connections on the port PostgreSQL is using (default is 5432). The specific steps depend on your operating system and your firewall software.

5. Configure your network:

If your machine is behind a router or a firewall, you might need to configure port forwarding to allow connections to PostgreSQL.



In a production setting, it's a good idea to limit access as much as possible. Use the IP of the BackupSheep server you are using with your integration.