Use the database on another host¶
At times, it’s necessary to relocate the database to another host, separate from the StaffCop service and admin interface. The steps are as follows:
Create a database and a user staffcop with all the required permissions on the remote host.
Update the PostgreSQL configuration file on the host:
Open /etc/postgresql/11/main/postgresql.conf.
Locate the line beginning with listen_addresses and uncomment it by removing the # symbol.
Add allowed IP addresses:
listen_addresses = '192.168.10.10, 192.168.10.112'
Here, 192.168.10.10 is the Staffcop server address, while 192.168.10.112 is the admin workstation, such as for pgAdmin.
Once you’ve made these adjustments, restart the server:
service postgresql restart
Transfer the database to another host. Use for reference following guides in this article. On the StaffCop Server, update the lines in /etc/staffcop/config with the remote server’s information:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'staffcop',
'USER': 'staffcop',
'PASSWORD': '1d6e8d9f8789400fed557937',
'HOST': '192.168.1.222',
'PORT': '5432',
},
}
Make sure to edit the fields Host and Password.
In file /etc/postgresql/11/main/pg_hba.conf, add an entry for the StaffCop Server in a similar format:
host staffcop staffcop 192.168.0.0/22 trust
Note
The database path can vary depending on the PostgreSQL version you’re using.
After moving the database to another host, make sure that the server is operational.
To simplify database configuration on the remote host, install StaffCop first. It will set up the database automatically. After restoring the backup from the main host, it’ll be ready to receive data.
You can then disactivate the StaffCop service on the local host.
To disable:
systemctl disable taffcop
To stop:
systemctl stop staffcop