Use the database on another host

Sometimes it’s necessary to place the database on another host, separate from StaffCop service and admin interface. The steps are the following:

  • Create a database and a user “staffcop” with all the required permissions on the remote host.

  • Then transfer the database to another host. For example following guides in this article.

  • On StaffCop Server - edit the following lines in /etc/staffcop/config by stating info of remote server:

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        'NAME': 'staffcop',
        'USER': 'staffcop',
        'PASSWORD': '1d6e8d9f8789400fed557937',
        'HOST': '192.168.1.222',
        'PORT': '5432',
    },
}

edit fields Host and password.

  • In file /etc/postgresql/11/main/pg_hba.conf add indent for StaffCop Server in a similar way:

host    staffcop        staffcop        192.168.0.0/22  trust

Note

The database path can be different, it depends on Postgresql version which you use!

  • Check the server operability after transferring the database to another host.

To simplify configuring of the database on the remote host you can install StaffCop beforehand, it will automatically configure the database and after restoring backup from the main host it will be ready to receive data from the main server. The StaffCop service on the local host can be disabled (systemctl disable taffcop) or stop (systemctl stop staffcop).