Sql-server – Sync two databases on different servers

Architecturedata synchronizationsql serversql-server-2012

I can't pick the right solution for my below requirement. Can you people please advise?

We have two SQL Server 2012 database servers:

  1. First one is in Texas (USA). Our client will use this for UAT.
  2. Second one is in Chennai (India). This one we will use for development/local testing.

While testing our application, the client will find issues/bugs in UAT environment, so we need to replicate to our development environment for further analysis, and to develop fixes for the bugs.

We are planning to sync two databases present in two different places. I am looking to synchronize the database in single direction. It should support write operations.

I have found a few potential solutions:

  1. Transaction Log Shipping

    In Transaction Log Shipping the secondary database is always in read only/restoring mode, so we can not perform any write operations. I need to do write operations to provide fixes for the issues/bugs. So I think log shipping will not be useful.

  2. Database Mirroring and Always On High Availability

    As a junior DBA, I don't have much knowledge of these. Please advise if these would fit for me.

  3. Scheduling a daily job

    Taking a backup of the UAT server and restoring it to our local development server, copying the database backup via FTP.

Can you please advise which solution will be the best fit for this?

Edit:-
I would like to move data changes happening in Database 1(Server 1) to Database 2(Server 2). After moving changes to database 2(Server 2) it should be writable mode. And i don't want to move changes happening in database 2(Server 2) to database 1 (Server 1). So it's a single direction sync.

Below image will gives better understanding.
enter image description here

Best Answer

For simplicity if this was for a limited time frame, i would go with backup and restores.

Unless you are required to respond within minutes you could probably get by with daily backups. You could even set up a job to take a backup and FTP it on demand, after they have reported a defect.

I wouldn't even bother restoring daily unless the issue was specific to newly created data. In my experience UAT is more about functionality. So you test with existing data and create new data. Having a db a few days behind theirs means you should be able repeat the test and reproduce the defect.

This approach would get slower, more difficult and less feasible the bigger the db is.

If you will be providing ongoing support, the db is huge, and you have SLA saying you have to respond within minutes, replication/synchronization of some sort might be worth the effort to set up.

The best solution for you may be dictated by client security or technical policies. Work with them to ensure what you are proposing is acceptable. If not keep in mind there are lots of variations on this theme. But it all boils down to: 1. you need something to take a back up, and 2. you need something to FTP the files either on a schedule or on demand.

If I was doing this personally I would begin with Ola Hallengren's backup scripts. After installing that I'd create a SQL Agent job which invokes the backup.

I would then edit the agent job to add a step to FTP the files. I just had a quick search and found this example of how to use SSIS to FTP a file and I found this example of an FTP script for SQL Server.

My recommendation is that you set this job up to run on a schedule, and only run it on demand if truly required. If you don't have remote access and permission to execute tasks, you can request someone on the client site execute the task for you.