Serverless Backups Automation
Omar Shubeilat
Warwick Business School | Oracle ACE Alum ? | Enterprise Performance Management Advisor
This is the second part of two blog series on serverless functions (also known as Functions-as-a-Service) in Oracle Cloud Infrastructure (OCI). In my first blog, I covered an overview of what is a serverless function and gave an example of a function that backs up an EPM Cloud application by invoking a Python based function. If you did not read the first part, here is the link.
In this second part, I will be focusing on automating the process from start to end using OCI Alarms and Notifications.
In a nutshell, the automation solution relies on monitoring services to track an object storage bucket and trigger an alarm if the number of backups is less than a predefined number, the same alarm trigger will call a function to backup the EPM application. The following diagram demonstrates what the solution components are.
Here is a breakdown of the solution:
- Key Vault - This is used to hold the encrypted credentials to avoid hard coding credentials and URL details in the function code
- Monitoring - This service provides object storage metrics that determine when the automation kicks in.
- Alarms - an alarm is used to monitor object storage buckets, and will kick off notification services if a condition is met
- Notifications - Notification topics are used to notify system administrators when the alarm is in firing mode and also used to invoke the function
- Functions - as described in my previous blog, this is the Python-based function that backs up the EPM Cloud application by calling a REST endpoint
Let me start with the vault, nothing fancy here, I just created a software key (software option is cheaper than HSM) and created two secrets to store my user password and authentication token and updated the function configuration to reference them as follows.
The next step is to create a subscription and notification topics to associate with the alarm. The administration team members will subscribe to this topic and will get notified every time the alarm is in firing mode. I have two subscriptions, one to send a notification email and another to trigger the backup function as follows.
领英推è
The final step is to create an alarm definition and configure it kick off if a certain condition is met. In my example, the alarm will kick off when the storage bucket has less than five backup files in the last hour.
Depending on the alarm condition, you may have to manually place the backup files before enabling the alarm. For example, if the alarm fires when number of files are less than 30, then you need some backups to be in the bucket, otherwise, the alarm will fire away the moment you enable it for the first time assuming the bucket is empty.
Every time the alarm is in firing mode, the oracle function will be invoked and the subscribers will receive an email notification as follows.
Here is a screenshot of the function metrics that includes function invocations and duration and here you can see the function has been invoked.
And the object storage bucket is looking good the backup files are piling up nicely.
This concludes my two part series on serverless backups. Hope you find it helpful.