Skip to content

Active-Passive Setup

An active-passive setup provides redundancy by maintaining a secondary (passive) server that can take over if the primary (active) server fails. This guide explains how to configure a Surfly active-passive setup.

Install the exact same version of Surfly on the passive node by following the installation documentation. Ensure all configuration steps are identical except for any host-specific settings.

On the active node, create dumps of both the Surfly and Console databases:

Terminal window
# Create Surfly database dump
pg_dump -U surfly_app surfly > ~/surfly_$(date +"%Y-%m-%d").sql
# Create Console database dump
pg_dump -U surfly_app console > ~/console_$(date +"%Y-%m-%d").sql

3. Transfer Database Dumps to Passive Node

Section titled “3. Transfer Database Dumps to Passive Node”

Copy the database dumps from the active to the passive node:

Terminal window
# From active node, replace PASSIVE_NODE_IP with your passive node's IP address
scp ~/surfly_*.sql ~/console_*.sql user@PASSIVE_NODE_IP:/tmp/

On the passive node, stop required services before database restoration:

Terminal window
systemctl --user stop ss-pgbouncer
sudo systemctl restart postgresql

Import the databases:

Terminal window
# For SQL files
dropdb -U postgres surfly && createdb -U postgres -O surfly_app -E UTF8 surfly && psql -U surfly_app surfly < /tmp/surfly_YYYY-MM-DD.sql
dropdb -U postgres console && createdb -U postgres -O surfly_app -E UTF8 console && psql -U surfly_app console < /tmp/console_YYYY-MM-DD.sql

Restart services after restoration:

Terminal window
systemctl --user start ss-surfly.target

To manually switch to the passive node:

  1. Update your load balancer configuration to direct traffic to the passive node
  2. Verify the passive node is operating correctly

For automatic failover, configure a load balancer as described in the Failover documentation.