Asynchronous Replication. Configuring Scheduled Snapshots
- October 14, 2015
- 8 min read
Introduction
A disaster recovery site is crucial for companies that care about their data and it’s A MUST for companies which are under regulatory requirements. On-site Redundancy (RAID, Synchronous Mirroring, etc.) does not guarantee data protection from hurricanes, floods and earthquakes that could completely destroy the primary datacenter. StarWind provides asynchronous replication functionality for maximum data security.
The combination of StarWind data-compression and replication technologies eliminate the issues of high cost, performance impacting and data integrity typical with conventional DR implementations. Allowing installation to take place in the cloud VM for DR purposes and moving the replication and data compression to the background, it prevents the common pitfalls found in traditional DR solutions.
This document is intended for StarWind users who want to learn asynchronous replication deployment and the basic snapshot management. It describes the process in details, being a comprehensive step-by-step instruction, good for beginner users as well as seasoned professionals.
A full set of up-to-date technical documentation can always be found here, or by pressing the Help button in the StarWind Management Console.
For any technical inquiries, please visit our online community, Frequently Asked Questions page, or use the support form to contact our technical support department.
Pre-Requisites
Asynchronous replication presumes that a certain number of data snapshots will be stored on a disaster recovery node. It also creates a need in rotating these snapshots, since administrator can run out of space on the server making it impossible to create new snapshots. This procedure must be as automated as possible to avoid any possibility of human error. 3 key statements are pointed out below:
• administrator should know how many snapshots he wants to have available all the time;
• administrator should know how often he wants to take snapshots;
• administrator should know his production workload to calculate growth of data in snapshots. StarWind snapshots are incremental.
This document explains how to schedule periodical snapshots using Windows Task Manager and StarWindX module. It implies having at least one main node and one replication node, further referred to as disaster recovery node. Please note that ability to take snapshots on the storage level is supported by StarWind Virtual SAN for thick image file. The documents on creating of the standalone image file and LSFS devices can be found by using the links below:
https://www.starwindsoftware.com/quick-start-guide-creating-stand-alone-image-file-device-withstarwind-virtual-san
For general information about asynchronous replication refer to the guide below:
http://www.starwindsoftware.com/whitepapers/asynchronous-replication.pdf
Implementing Snapshot Rotation
First, in StarWind Management Console create a device and attach it to target. Creating devices and attaching them to targets is described in Quick Start Guide below: http://www.starwindsoftware.com/starwind-virtual-san-free-getting-started-guide
1. Once the device is created, navigate to its replication manager and select “Add Replica”:
2. The next step is to choose “Asynchronous One-Way Replication”:
3. Type in the hostname or IP of disaster recovery node:
4. Create new partner device:
5. Specify path to the partner device header file:
6. Click on “Change Network Settings”:
7. Specify network interfaces for asynchronous replication:
8. Specify path to journal files on both nodes:
9. Create replica:
10. Click finish to exit the wizard. The following status window will appear:
11. Navigate to “Snapshot Manager” menu of your newly created device:
12. Create your first snapshot:
13. The result will look as follows:
14. By clicking on a particular snapshot’s “Mount” button it is possible to restore both images on main and disaster recovery nodes to the state when this snapshot was taken.
Scheduling Snapshots
Make sure StarWindX module is installed. It comes with default StarWind installation package.
First, determine how many snapshots you would like to store at a time in order to implement proper snapshot rotation. It is ‘15’ in this case. Download or copy the PowerShell script below:
https://www.starwindsoftware.com/tmplink/snapshot_script.ps1
Replace the following with your own parameters:
%%main_node_name%%
%%disaster_recovery_node_name%%
%%number_of_snapshots%%
%%device_name%%
%%replication_device_name%%
FOR EXAMPLE:
mynode1
mynode2
15
HAImage6
HAImage7
When determining the number of snapshots required, you should note that they are incremental, i.e. every next snapshot is written over the other only by adding modified data on top of it. So, you should consider a higher number of snapshots if data amount on your device increases not too fast. Otherwise, consider a number that is reasonable not to run out of disk space.
Once the script is modified, save it as snapshot_script.ps1 on C:\. Then go to Control Panel > Task
Scheduler > Create Basic Task, and follow the wizard steps:
1. Choose Daily and click Next:
2. Give a name to your task and click Next:
3. Click Next again:
4. Select “Start A Program” and click Next:
5. In “Program/script” field indicate “powershell.exe”. In “Add arguments” type in the following:
-ExecutionPolicy Bypass -NonInteractive -NoProfile -WindowStyle Hidden 2>&1 -File
snapshot_script.ps1 | Tee-Object “C:\log\trace.log” -Append
This will allow to log both failed and successful runs for further troubleshooting. Here path to the log file is set to “C:\log\trace.log”
Click Next.
6. Below is an overview of the resulting window:
7. Tick “Run whether user is logged or not” and “Run with highest privileges”.
8. Navigate to triggers tab and click “Edit Trigger”. Here specify how often you would like to run the script. In the sample below script is set to run every hour on the date of creation and then once a day with no expiration date.
9. Click Ok and exit task Scheduler wizard.
10. Open PowerShell as Administrator and set execution policy to unrestricted by running the command below:
Set-ExecutionPolicy unrestricted
11. Make sure the script is working as expected by checking Starwind Snapshot manager or running the script manually in powershell. There should be no errors:
Sample output:
_____________________
17 August 2014 18:59:25 Connecting to sw-sup-sw-hv1 True
17 August 2014 18:59:26 Successfully logged onto the server
17 August 2014 18:59:26 You have 4 snapshots available
17 August 2014 18:59:26 4 is too much for you. Let’s delete the oldest one
17 August 2014 18:59:26 Connecting to sw-sup-sw-hv2 True
17 August 2014 18:59:26 Successfully logged onto the server
17 August 2014 18:59:26 Removing the oldest snapshot
17 August 2014 18:59:26 Snapshot 6 has been removed
17 August 2014 18:59:26 Taking new snapshot
17 August 2014 18:59:56 Snapshot taken
_____________________
The script will remove the latest snapshot and replace it with the new one. Note that this script will not delete all snapshots you created manually before using the script, so you’ll need to remove them manually in StarWind Console.
Best practice is to periodically check snapshot logs to ensure that scheduled procedures are running correctly.
Summary
Having automated snapshot rotation saves a considerable amount of time for system administrator.
In the nearest future, such application will be added to StarWind management console. In the meantime, PowerShell scripting is a perfect workaround for this.