<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Antoun Moubarak</title>
    <description>The latest articles on DEV Community by Antoun Moubarak (@amoubarak).</description>
    <link>https://dev.to/amoubarak</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3537546%2F4d36939e-8f9e-4137-9e4f-ef88db13ae6b.png</url>
      <title>DEV Community: Antoun Moubarak</title>
      <link>https://dev.to/amoubarak</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/amoubarak"/>
    <language>en</language>
    <item>
      <title>Automate Disaster Recovery Plan Validation in OCI Using a Custom Precheck Tool</title>
      <dc:creator>Antoun Moubarak</dc:creator>
      <pubDate>Mon, 06 Oct 2025 10:27:29 +0000</pubDate>
      <link>https://dev.to/amoubarak/automate-disaster-recovery-plan-validation-in-oci-using-a-custom-precheck-tool-1omo</link>
      <guid>https://dev.to/amoubarak/automate-disaster-recovery-plan-validation-in-oci-using-a-custom-precheck-tool-1omo</guid>
      <description>&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;Disaster Recovery (DR) planning is a fundamental pillar of any high-availability architecture, ensuring business continuity in the face of unexpected disruptions. In Oracle Cloud Infrastructure (OCI), Full Stack Disaster Recovery (FSDR) takes DR to the next level by automating and orchestrating recovery processes across OCI regions.&lt;/p&gt;

&lt;p&gt;At the heart of OCI’s FSDR service is the Disaster Recovery Protection Group (DRPG) — a logical collection of related OCI resources such as compute instances, databases, and more, that need to be recovered together to maintain system integrity. Within a DRPG, DR Plans define the precise sequence of actions necessary for failover, switchover, and DR drills, ensuring recovery efforts are seamless and efficient.&lt;/p&gt;

&lt;p&gt;But how can you be certain that your DR plans are foolproof and ready to execute when disaster strikes?&lt;/p&gt;

&lt;p&gt;To help teams proactively validate their DR plans, this CLI-based Precheck Tool verifies the configuration of all active DR plans within a given DRPG. It identifies potential misconfigurations or missing dependencies before executing failover or switchover actions — helping you catch issues early.&lt;/p&gt;

&lt;p&gt;In this blog, we’ll walk through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What the tool does&lt;/li&gt;
&lt;li&gt;How it works&lt;/li&gt;
&lt;li&gt;How to use it&lt;/li&gt;
&lt;li&gt;How it integrates with OCI Notifications&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What the Tool Does
&lt;/h2&gt;

&lt;p&gt;This Python-based tool automates the validation (precheck) of all active DR plans associated with an OCI Disaster Recovery Protection Group (DRPG). It:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automatically identifies whether the DRPG is primary or standby&lt;/li&gt;
&lt;li&gt;Executes prechecks for each DR plan (Switchover, Failover, Start Drill, Stop Drill)&lt;/li&gt;
&lt;li&gt;Waits for precheck completion and logs the results&lt;/li&gt;
&lt;li&gt;Sends notifications via OCI Notification Topics (email/SMS/etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;This tool is especially useful for validating DR readiness as part of a scheduled job.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How It Works
&lt;/h2&gt;

&lt;p&gt;The tool leverages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OCI Python SDK for interacting with the DR services and notifications&lt;/li&gt;
&lt;li&gt;Instance Principals for secure authentication inside OCI Compute&lt;/li&gt;
&lt;li&gt;Structured logging to file and console&lt;/li&gt;
&lt;li&gt;Email alerts via OCI Notification Topic if &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here’s what a basic run looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python full_stack_dr_plans_precheck.py -id ocid1.drprotectiongroup.oc1..xxxxx -nf ocid1.onstopic.oc1..yyyyy
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Required:

-id DRPG_OCID, --drpg-ocid DRPG_OCID: 
OCID of the DR Protection Group (can be primary or standby)

Optional:

-nf ONS_TOPIC_OCID, --ons-topic-ocid ONS_TOPIC_OCID: 
OCID of the OCI Notification Topic for alerting
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What Gets Logged
&lt;/h2&gt;

&lt;p&gt;During execution, the tool creates in the logs/ directory and writes:&lt;/p&gt;

&lt;p&gt;All INFO logs to: .log&lt;/p&gt;

&lt;p&gt;If enabled, a notification is sent using the specified Notification Topic.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Example Output
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2025-09-29 12:01:32 INFO     Standby DRPG: drpg-ashburn (ocid1.drpg...) is ACTIVE
2025-09-29 12:01:34 INFO     Running precheck for FAILOVER plan: app-dr-failover
2025-09-29 12:01:54 INFO     Precheck passed: app-dr-failover
2025-09-29 12:02:01 INFO     Running precheck for SWITCHOVER plan: app-dr-switchover
2025-09-29 12:02:19 ERROR    Precheck failed: app-dr-switchover
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Notification Example&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The tool automatically publishes an alert via OCI Notifications.&lt;/p&gt;

&lt;p&gt;Subject:&lt;br&gt;
&lt;em&gt;FSDR Precheck Results for drpg-ashburn - ocid1.drprotectiongroup...&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Body:&lt;br&gt;
&lt;em&gt;drpg-ashburn: ocid1.drprotectiongroup.oc1..aaaa...&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;2025-09-29 12:02:19 ERROR    Precheck failed: app-dr-switchover&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Installation &amp;amp; Setup
&lt;/h2&gt;

&lt;p&gt;Ensure the script is run inside an OCI Compute instance with Instance Principal access.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clone the &lt;a href="https://github.com/antounmoubarak/full-stack-dr-plans-precheck" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt; repo:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;git clone https://github.com/antounmoubarak/full-stack-dr-plans-precheck.git&lt;br&gt;
cd full-stack-dr-plans-precheck&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Install dependencies:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pip install -r requirements.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Run the tool:
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;python full_stack_dr_plans_precheck.py -id &amp;lt;your_drpg_ocid&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;(Optional) Add --ons-topic-ocid to receive email alerts.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Security Notes
&lt;/h2&gt;

&lt;p&gt;This script uses Instance Principal Authentication, so no API keys or secrets are stored locally.&lt;br&gt;
All regional configuration is temporary and deleted after execution.&lt;/p&gt;
&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Disaster Recovery isn’t just about having a plan — it’s about knowing that plan works. Automating your prechecks gives you a safety net and builds trust in your cloud architecture.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Next Step: &lt;br&gt;
Add scheduling via &lt;code&gt;cron&lt;/code&gt; or any other scheduling tool.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To set up a cron job on Oracle Linux VMs that runs the script every day at 00:00 (midnight), follow these steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open the Crontab Editor
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;crontab -e
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This opens the user's crontab file in the default text editor (usually vi or nano).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add the Cron Job&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Assuming the Python script is located in the directory: &lt;code&gt;/home/opc/full-stack-dr-plans-precheck&lt;/code&gt;, add this line at the bottom of the file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;0 0 * * * /home/opc/full-stack-dr-plans-precheck/full_stack_dr_plans_precheck.py -id &amp;lt;drpg_ocid&amp;gt; -nf &amp;lt;topic_ocid&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;0 0 * * * = Every day at 00:00&lt;br&gt;
Make sure the script is executable.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Save and Exit&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In &lt;code&gt;vi&lt;/code&gt;: Press &lt;code&gt;Esc&lt;/code&gt;, then type &lt;code&gt;:wq&lt;/code&gt; and press &lt;code&gt;Enter&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In &lt;code&gt;nano&lt;/code&gt;: Press &lt;code&gt;Ctrl+O&lt;/code&gt;, &lt;code&gt;Enter&lt;/code&gt;, then &lt;code&gt;Ctrl+X&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Verify the Cron Job is Installed&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;crontab -l
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will list the current user's cron jobs and should include your new entry.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Check Cron Service Status&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Make sure the crond service is running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl status crond
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If it’s not running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo systemctl start crond
sudo systemctl enable crond
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>oci</category>
      <category>fsdr</category>
      <category>disaster</category>
      <category>recovery</category>
    </item>
  </channel>
</rss>
