Goal
You have an NFS file system on OCI File Storage that an application can't lose. Snapshots in the same availability domain don't cover an AD or region outage. File Storage replication copies the file system to a target file system in another AD or region on a schedule. This runbook covers four things: building the replication, proving it keeps up, failing over during an incident, and failing back.
How it works:
- A replication resource on the source and a replication target on the target are created together.
- At every interval the service takes a replication snapshot, transfers the changed data and applies it to the target. These delta cycle states show in the Console as Idle, Capturing, Transferring and Applying.
- The target file system is read-only while replication is running. You can't export it directly. To fail over, you clone the last applied snapshot and export the clone.
1. Check the prerequisites
- The target has never been exported. Only a file system that has never been exported can be a target. If you want to reuse an old file system, clone it first and use the clone.
- The target has no snapshot policy attached, no user snapshots created or deleted on it, and no quota rules that differ from the source.
- For cross-region replication, the tenancy is subscribed to the destination region.
- A mount target and export set already exist in the DR AD or region, so you only need to add an export at failover time.
- The target file system has its own encryption key and tags. Keys and tags are not replicated.
- IAM for the operators:
Allow group StorageAdmins to manage replications in compartment prod-storage
Allow group StorageAdmins to manage file-systems in compartment prod-storage
Allow group StorageAdmins to manage export-sets in compartment prod-storage
Allow group StorageAdmins to use tag-namespaces in compartment prod-storage
Note
Clones of the source are not replicated, and each file system supports a limited number of replications (three at the time of writing). Check the current limits before you design a fan-out.
2. Create the target and the replication
Create an empty target file system in the DR region:
SRC_REGION=eu-frankfurt-1
DR_REGION=eu-amsterdam-1
COMP=ocid1.compartment.oc1..aaaa...
DR_AD=$(oci iam availability-domain list --region $DR_REGION \
--query 'data[0].name' --raw-output)
TARGET_FS=$(oci fs file-system create --region $DR_REGION \
--availability-domain "$DR_AD" --compartment-id $COMP \
--display-name app-share-dr-target \
--wait-for-state ACTIVE --query 'data.id' --raw-output)
Create the replication in the source region. The interval is in minutes, and the minimum is 15:
SOURCE_FS=ocid1.filesystem.oc1.eu-frankfurt-1.aaaa...
oci fs replication create --region $SRC_REGION \
--compartment-id $COMP \
--source-id $SOURCE_FS \
--target-id $TARGET_FS \
--replication-interval 60 \
--display-name app-share-to-ams \
--wait-for-state ACTIVE
The first cycle copies the whole file system, so it can take hours for large shares. Later cycles transfer only the changes. Your achievable RPO is about one interval plus the time a cycle takes. If the change rate is high, a cycle can run longer than the interval. Before you commit to an RPO, run oci fs file-system estimate-replication --help and use that command to estimate the transfer time for your change rate.
3. Check that replication is keeping up
List the replications and their state:
SRC_AD=$(oci fs file-system get --region $SRC_REGION --file-system-id $SOURCE_FS \
--query 'data."availability-domain"' --raw-output)
oci fs replication list --region $SRC_REGION \
--compartment-id $COMP --availability-domain "$SRC_AD" \
--query 'data[].{name:"display-name",state:"lifecycle-state",id:id}' --output table
Get the details for one replication:
oci fs replication get --region $SRC_REGION --replication-id <replication-ocid> \
--query 'data.{state:"lifecycle-state",delta:"delta-status",progress:"delta-progress",rpo:"recovery-point-time",lastSnap:"last-snapshot-id"}'
Field names can vary between CLI versions. If any come back null, run the command without --query and read the raw JSON.
The value to watch is recovery point age. In the oci_filestorage namespace it is published as the metric ReplicationRecoveryPointAge, on both the replication and the replication target. It shows how far the target is behind the source. Set an alarm on it in the source region:
ReplicationRecoveryPointAge[5m]{resourceId = "<replication-ocid>"}.max() > <threshold>
Set the threshold to about two intervals. Check the metric's unit in Metrics Explorer before you pick a number. Also chart ReplicationThroughput. For cross-region replication, chart ReplicationEgressThroughput too, because cross-region traffic is billed as egress.
| Symptom | Likely cause | Fix |
|---|---|---|
| Create fails: target not eligible | Target was exported once, has a snapshot policy or has user snapshots | Create a new empty target, or clone the old one and use the clone |
| Recovery point age keeps growing | Change rate is higher than the throughput a cycle can achieve | Raise the interval to a realistic value, cut churn (for example, temp files on the share) or split the data across file systems |
Lifecycle state FAILED | Target deleted or changed, or a key problem | Read the work request, delete the replication and recreate it with a fresh target |
| First sync never finishes | Very large initial copy | Wait, and track progress with ReplicationThroughput. Don't run DR tests yet |
4. Fail over to the target
Use this when the source AD or region is down, or when you run a planned DR test.
4.1 Find the last applied replication snapshot
Replication snapshots follow the name pattern replication-snapshot-<number>-<creation-time-UTC>:
oci fs snapshot list --region $DR_REGION --file-system-id $TARGET_FS \
--query 'data[].{name:name,created:"time-created",id:id}' --output table
Pick the newest one. Its creation time is your recovery point, so write it in the incident record.
4.2 Clone it to a new, writable file system
FAILOVER_FS=$(oci fs file-system create --region $DR_REGION \
--availability-domain "$DR_AD" --compartment-id $COMP \
--source-snapshot-id <replication-snapshot-ocid> \
--display-name app-share-failover \
--wait-for-state ACTIVE --query 'data.id' --raw-output)
The clone is available within minutes regardless of its size. You can pass --clone-attach-status DETACH to make it a full copy that is independent of the parent.
4.3 Stop replication
If the source region is down, delete the replication target in the DR region. If you don't, replication resumes when the source comes back:
oci fs replication-target list --region $DR_REGION \
--compartment-id $COMP --availability-domain "$DR_AD"
oci fs replication-target delete --region $DR_REGION \
--replication-target-id <replication-target-ocid>
If you are running a test and the source is still up, delete the replication in the source region instead. Its replication target is deleted with it.
Caution
When the replication is deleted, its replication snapshots on the target become user snapshots. If you delete those snapshots, that file system can never be a replication target again. Leave them alone until failback is complete.
4.4 Export and mount the clone
EXPORT_SET=$(oci fs mount-target get --region $DR_REGION \
--mount-target-id <dr-mount-target-ocid> \
--query 'data."export-set-id"' --raw-output)
oci fs export create --region $DR_REGION \
--export-set-id $EXPORT_SET --file-system-id $FAILOVER_FS --path /app-share
On the DR clients:
sudo mount -t nfs -o vers=3,hard,timeo=600 <dr-mount-target-ip>:/app-share /mnt/app-share
Add any export options you use on the source (source CIDRs, root squash) to the new export. Export options are not part of replication.
5. Fail back
- When the source region is healthy, check that the old source file system is still there. Delete any replication on it that is left in
FAILED. - Reverse replication: create a replication from the DR clone (
$FAILOVER_FS) to a new, never-exported file system in the original region. If you want to use the old source as the target, clone it first. - Wait for recovery point age to fall below one interval. Then stop writes on the DR side, let one more cycle finish, and repeat steps 4.1 to 4.4 in the original region.
- Recreate the forward replication from the new primary file system. Then clean up the temporary clones and snapshots.
Warning
Any write made to the old source after failover is not on the DR clone. Before you reverse replication, compare the two file systems and decide which data wins. Otherwise you overwrite it silently.
Prevent it next time
- Store the failover script, with the DR region, AD, mount target and export path filled in, next to the runbook. Then a failover takes four commands, not an hour of console clicking.
- Run a DR test every quarter on a clone, without stopping production replication. Time each step and record the recovery point you achieved.
- Alarm on
ReplicationRecoveryPointAgeand on replication lifecycle changes (with an Events rule). Route both to the on-call topic. - Keep encryption keys, tags, export options and NSGs for the DR side in Terraform, because none of them are replicated.
- Review the interval when the change rate grows. An RPO the replication can't deliver is worse than an honest, longer one.
Get the weekly HubDatAI email
One email a week with everything new: posts, learning sessions and videos. Free, no spam, unsubscribe in one click. What you get