Skip to main content

Account Replication & Replication Groups

For years, Snowflake administrators could only replicate databases between regions (e.g., AWS Mumbai to AWS Singapore). However, what happens when a disaster strikes and your team fails over to the secondary region, only to find that none of the Users, Roles, or Virtual Warehouses exist there?

To solve this, Snowflake introduced Account Replication, powered by Replication Groups.

Topics Covered​

  • What is Account Replication?
  • Replication Groups vs Failover Groups
  • Creating a Replication Group
  • Refresh Scheduling and Monitoring

What is Account Replication?​

Account Replication extends cross-region sync capabilities beyond just data. It allows you to replicate Account-level metadata, ensuring your secondary environment is a perfect mirror of your primary environment.

Objects you can (and should) replicate include:

  • Security: Users, Roles, Network Policies
  • Compute: Virtual Warehouses, Resource Monitors
  • Integrations: Storage Integrations, Security Integrations

(Note: Account Replication requires the Business Critical Edition or higher.)

Replication Groups vs Failover Groups​

When configuring this, you must choose between two types of groups.

  1. Replication Group: Simply copies data and metadata from a Primary account to one or more Secondary accounts. It does not allow the Secondary account to assume the Primary role. (Useful for read-only analytics in other regions).
  2. Failover Group: Does everything a Replication Group does, but additionally allows you to execute a command that demotes the Primary account and promotes the Secondary account to become the new Primary. (Crucial for Disaster Recovery).

Hands-On: Configuring a Failover Group​

Let's assume our Primary account is in AWS Mumbai (orgname-aws_mumbai) and our Secondary account is in Azure Pune (orgname-azure_pune).

We want to replicate our core databases along with all Users and Roles.

1. Linking the Accounts​

First, the Organization Administrator must explicitly allow these two accounts to replicate to each other.

(To ensure you have the ORGADMIN role required for this step, check your current role with SELECT CURRENT_ROLE();)

USE ROLE ORGADMIN;

-- Allow Mumbai to replicate to Pune
SELECT SYSTEM$GLOBAL_ACCOUNT_SET_PARAMETER(
'orgname.aws_mumbai',
'ENABLE_ACCOUNT_DATABASE_REPLICATION',
'true'
);

2. Creating the Failover Group (In Primary - Mumbai)​

Now, we log into the Primary account and define what gets replicated.

USE ROLE ACCOUNTADMIN;

CREATE FAILOVER GROUP FG_MUMBAI_TO_PUNE
OBJECT_TYPES = USERS, ROLES, DATABASES, WAREHOUSES
ALLOWED_DATABASES = BEEMS_PROD_DB, BEEMS_HR_DB
ALLOWED_ACCOUNTS = orgname.azure_pune
REPLICATION_SCHEDULE = '60 MINUTE';

Note: Because we added a REPLICATION_SCHEDULE, Snowflake will automatically sync changes to Pune every hour.

3. Creating the Replica (In Secondary - Pune)​

We must log into the Secondary account and create the linked replica. It will not receive data until we do this.

-- Run this in the Azure Pune account
USE ROLE ACCOUNTADMIN;

CREATE FAILOVER GROUP FG_MUMBAI_TO_PUNE
AS REPLICA OF orgname.aws_mumbai.FG_MUMBAI_TO_PUNE;

Once this command executes, the initial replication begins. All users, roles, warehouses, and the specified databases are securely copied from AWS Mumbai to Azure Pune.

Monitoring Replication Status​

Replication is a background process. If an executive asks, "Is our disaster recovery region up to date?", you must know how to check the lag.

-- Check the refresh history in the Primary account
SELECT
REPLICATION_GROUP_NAME,
PHASE_NAME,
START_TIME,
END_TIME,
ERROR_CODE,
ERROR_MESSAGE
FROM table(information_schema.replication_group_refresh_history(
'FG_MUMBAI_TO_PUNE'
))
ORDER BY START_TIME DESC;

Common Troubleshooting Tips:

  • Users Cannot Log In: If users exist in the primary but can't log into the secondary, check if USERS and ROLES were included in the OBJECT_TYPES list of the replication group.
  • Dangling References: If you replicate a database that relies on a Storage Integration, but you forget to include INTEGRATIONS in the replication group, your external tables or Snowpipes will break in the secondary region.

Summary​

  • Account Replication ensures Users, Roles, Warehouses, and Integrations are synced across regions.
  • Failover Groups are required if you intend to promote a secondary region to Primary during an outage.
  • Use CREATE FAILOVER GROUP to define exactly what objects to sync and how often.
  • Always monitor REPLICATION_GROUP_REFRESH_HISTORY to ensure your RPO (Recovery Point Objective) targets are being met.