---
# How to setup Snowflake backup confirmation and alert notifications
**URL:** https://www.sigmoid.com/blogs/how-to-setup-snowflake-backup-confirmation-and-alert-notifications/
Date: 2022-06-15
Author: Sigmoid
Post Type: post
Summary: Data backups are key to ensuring business continuity. However, it is important to track if the backups are successful with a notification...Read More...
Categories: Cloud Transformation
Tags: Data Management
Featured Image: https://www.sigmoid.com/wp-content/uploads/2023/11/How-to-setup-Snowflake-backup-confirmation-and-alert-notifications-banner-opt.jpg
---
Data backups are key to ensuring business continuity. However, it is important to track if the backups are successful with a notification system without incurring any significant additional costs.
Due to the lack of sufficient [Snowflake](/ebooks-whitepapers/snowflake-implementation/) documentation on backup alerting, this blog discusses how to set up alerts to monitor backup task in Snowflake. We will cover setting up AWS Services such as: SNS, Lambda and EventBridge to monitor backup task in Snowflake. Here are the steps for implementing monitoring and alerting for a Snowflake backup task.
- Step 1: Setting Up AWS SNS Topic
- Step 2: Setting up AWS Lambda Function
- Step 3: Setting up AWS EventBridge Rule
## Prerequisites
Consider an existing scheduled backup task in Snowflake, scheduled with cron expression. You can have a backup task that calls a stored procedure, a set of sql statements. Then this stored procedure backs up tables of snowflakes in S3 path through S3 stage. Let’s consider we have a backup task called backup_task that is scheduled to run at 4:00 p.m daily. This backup_task then calls a procedure called snowflake_database that backs up tables called sample1_table and sample2_table in S3 path through a S3 stage called my_s3_stage.
Below is an example of how a backup task can look like:

Example of Backup Task
By default snowflake tasks are created in suspended mode. You have to start them using the following command:

Backup confirmation/failed alerts are crucial to be aware that our data is being backed up on a timely basis. Let’s assume that backup task in snowflake is scheduled at 4:00 PM daily, we will schedule **AWS EventBridge** to run daily at 4:01 PM using a cron job and trigger a **Lambda Function** that access the snowflake database and checks if that backup task has executed successfully or not. If the backup task has executed successfully we will receive a backup confirmation notification, if not then a backup failed notification will be received so that an action can be taken as early as possible.

Fig 1. Flow of Backup Success or Failed Alert Mechanism
### Step 1: Setting up AWS SNS topic:
Make sure to have **AWS SNS Topic** with confirmed subscription in place.
Now edit the **Access Policy** of SNS Topic with following permissions:
**NOTE:** Replace with the **Region** that this notification is for. Replace with your **account ID**. Replace with the **SNS topic name**.

Access Policy for SNS Topic
### Step 2: Setting up AWS Lambda function:
Prerequisites:
- **AWS IAM Role** for Lambda function with **LambdaBasicExecution** Policy and **SNS: Publish** permission attached.
- Import **Snowflake connector module** by creating a custom **Lambda Layer**.
Steps:
- Create a Lambda function with Python 3.8 Runtime.
- Choose **IAM Role** created for lambda function.
- Add permission for **Lambda function** to be invoked from **AWS EventBridge Rule**. Go to configuration tab in Lambda function, select permissions tab, scroll down to **Resource-based policy**, click add permissions. Now add permissions like in the image below.
**Note:** Replace source account with your AWS Account ID. In Source ARN add your EventBridge Rule ARN.

Fig 2. Resource Based Policy for Lambda Function
- Add **Snowflake username, password, account and database** by going to** Configuration > Environment Variables.**
- Add the following code in **Lambda Function**.
The following **Lambda function** accesses the snowflake database with the credentials provided. In statement_3, we are checking if the backup_task has failed with an error with task_history. This table function can be used to query the history of task usage within a specified date range. The function returns the history of task usage for your entire Snowflake account or a specified task. [Learn more](https://docs.snowflake.com/en/sql-reference/functions/task_history.html).
Then we are fetching the output from statement_3 and counting if row fetched is 1. As we are only fetching only 1 row from query in statement_3 result_limit => 1 that means history of last executed backup_task is fetched making sure it has executed with error, ERROR_ONLY => true.
Then, rowCount is storing the number of rows fetched and if rowCount > 0, Backup failed **SNS notification** is sent through the **SNS Topic ARN** specified. Moreover, we are also storing the output of statement_3 as stored in the rows variable and storing the error_message column in the res variable to include that in the email alert body.
If rowCount equals to 0 then backup confirmation **SNS notification** is sent through the **SNS Topic ARN** specified.

Lambda Function Python Code
### Step 3: Setting up AWS EventBridge rule:
- Go to the **Amazon EventBridge** console [https://console.aws.amazon.com/events/](https://signin.aws.amazon.com/signin?redirect_uri=https%3A%2F%2Fap-northeast-1.console.aws.amazon.com%2Fevents%3FhashArgs%3D%2523%26isauthcode%3Dtrue%26region%3Dap-northeast-1%26state%3DhashArgsFromTB_ap-northeast-1_349c605b47913254&client_id=arn%3Aaws%3Asignin%3A%3A%3Aconsole%2Fevents&forceMobileApp=0&code_challenge=DZufTd0MkleJ2rmLnzByqs-mMogOwI3_dbKEZ_O2-fg&code_challenge_method=SHA-256).
- Go to the navigation pane and choose **Rules**.
- Click **Create rule**.
Enter a name and description for the rule.
A rule can’t have the same name as another rule in the same Region and on the same event bus.
- For the Event **bus**, choose default.
- For **Rule type**, choose **Schedule**
- Click **Next**.
- For **Schedule Pattern**, **choose A fine-grained schedule that runs at a specific time, such as 8:00 a.m. PST on the first Monday of every month**.
- Enter Cron expression: For ex: 31 10 * * ? *
- Click **Next**.
- For **Target types**, choose **AWS service**.
- For **Select a target, choose Lambda Function**.
- Select **Lambda Function** as configured earlier.
- Click **Next**.
- (Optional) Enter one or more tags for the rule.
- Click **Next**.
- Review the details of the rule and click **Create rule**.
Following is the example of how Backup Confirmation/Failed alert is received

Fig 3. Example of Backup Confirmation Notification

Fig 4. Example of Backup Failed Alert
## About the author
Prajna Bahuguna is a [DevOps Engineer](/data-devops/) at Sigmoid. She is a DevOps enthusiast who is always curious to learn about innovative solutions using Cloud, Python and Devops practices. In her leisure time she enjoys doing artwork and mobile photography.
[lc_the_tags]
## Featured blogs
[lc_get_posts post_type="post"
posts_per_page="4" orderby="date" output_view="lc_get_posts_mycustom_view" output_number_of_columns="4"
output_wrapper_class="row" output_article_class="shadow" output_hide_elements="Excerpt"
output_excerpt_length="0" output_excerpt_text="Read More" output_heading_tag="span"
output_featured_image_format="thumbnail" output_featured_image_class="card-img-left" ]
## Share
[addtoany]
Subscribe to get latest insights
## Talk to our experts
Get the best ROI with Sigmoid’s services in data engineering and AI
## Suggested readings
[View all](/blogs/)

#### [5 Ways IoT-Based Predictive Maintenance Generates Business Value](/blogs/iot-based-predictive-maintenance/)
[Read blog](/blogs/iot-based-predictive-maintenance/)

#### [Creating a single source of truth for banks to accelerate productivity and customer satisfaction](/blogs/single-source-of-truth-for-banks/)
[Read blog](/blogs/single-source-of-truth-for-banks/)

#### [Real-time marketing measurement with multi-touch attribution for CPG](/blogs/real-time-marketing-measurement-with-multi-touch-attribution-for-cpg/)
[Read blog](/blogs/real-time-marketing-measurement-with-multi-touch-attribution-for-cpg/)
---
## Categories
- Cloud Transformation
---
## Navigation
- [Company](/about-sigmoid)
- [Newsroom](/newsroom)
- [Life at Sigmoid](/careers)
- [Takshashila](/takshashila)
- [Contact Us](/contact-us)
- [AI Strategy Blueprint your AI advantage](/enterprise-ai-strategy/)
- [Generative AI Drive innovation with Generative AI](/generative-ai/)
- [Responsible AI Build trust with ethical AI practices](/responsible-ai-in-enterprise/)
- [Agentic AI Reshape business with scalable agentic systems](/agentic-ai-solutions/)
- [AI Managed Services Ensure reliable AI performance](/ai-managed-services/)
- [Advanced Analytics Transform your business with data-driven insights](/advanced-data-analytics-solutions/)
- [Start Assessment](/agentic-ai-readiness-index/)
- [Data Strategy Strong data foundations for scalable AI](/data-analytics-strategy/)
- [Data Management Leverage data as a strategic asset](/ai-data-management-services/)
- [Data Ops Automate data for speed and quality](/data-devops/)
- [Data Engineering Deliver insights faster with scalable pipelines](/data-engineering/)
- [Cloud Transformation Modernize data to maximise efficiency](/cloud-migration/)
- [Download Whitepaper](/ebooks-whitepapers/building-data-products-in-a-data-mesh-to-drive-business-value/)
- [Data Modeling Structure data for better decisions](/data-modeling-services/)
- [Data Visualization Transform data into actionable stories](/data-visualization-service/)
- [BI Migration Enhance decision making with modern BI tools](/bi-migration/)
- [Data Observability Build trust with healthy, accurate data](/data-observability/)
- [Automated Insights Make smarter decisions with auto-generated insights](/automated-insights/)
- [Download Whitepaper](/ebooks-whitepapers/power-bi-hacks/)
- [CPG & Retail End-to-end analytics for planning, operations, and commercial excellence](/industries/cpg-analytics/)
- [Life Sciences Trusted intelligence across clinical, commercial, and operational workflows](/industries/life-sciences/)
- [Financial Services AI-powered analytics for risk, compliance and customer experience](/industries/banking-financial-analytics-services/)
- [Read case study](/case-studies/data-clean-room-enables-real-time-insights-to-improve-operational-efficiency/)
- [MediaIQ Advanced platform for in-flight marketing measurement](/accelerators/sigmoid-mediaiq-multi-touch-attribution-tool/)
- [CampaignIQ AI-driven platform for optimized campaign budget allocation](/accelerators/sigmoid-campaigniq/)
- [AssistBot GenAI email assistant that automates human-like responses](/accelerators/sigmoid-assistbot-for-ai-email-assistant/)
- [CreativeBot GenAI tool for personalized and brand-aligned creative design](/accelerators/sigmoid-creativebot/)
- [SocialBot GenAI platform to analyze digital conversations and trends](/accelerators/#marketing|socialbot)
- [DemandIQ Predict trends accurately and optimize inventory management](/accelerators/sigmoid-demandiq/)
- [NetworkIQ Track and optimize logistics operations in real-time to quickly address disruptions](/accelerators/sigmoid-networkiq/)
- [SupplyIQ End-to-end platform to optimize supply chain operations](/accelerators/sigmoid-supplyiq/)
- [ProcurementIQ Automated procurement operations for maximum savings, compliance and efficiency](/accelerators/sigmoid-procurementiq/)
- [RapidML Accelerated deployment for machine learning models](/accelerators/sigmoid-rapidml/)
- [DataGuard Comprehensive platform for proactive data quality management](/accelerators/data-quality-tool-sigmoid-dataguard/)
- [CloudPulse Cloud cost optimization platform with multi-cloud management](/accelerators/sigmoid-cloudpulse/)
- [RAPID GenAI foundation with built-in governance and cost clarity](/accelerators/sigmoid-rapid/)
- [AnalyticsBot GenAI based platform to streamline decision-making in analytics](/accelerators/sigmoid-analyticsbot/)
- [DataConnect Seamlessly ingest, integrate and harmonize data from diverse sources](/accelerators/sigmoid-dataconnect/)
- [Reconica AI-powered data harmonization and reconciliation engine](/accelerators/sigmoid-reconica/)
- [ConverseBot GenAI driven insights generation for automated insights from reports](/accelerators/#sales|conversebot)
- [iNRM Cross-lever revenue growth optimization platform](/accelerators/sigmoid-inrm/)
- [AssortmentIQ Optimize shelf layouts and assortment mix at scale with AI-based insights](/accelerators/sigmoid-assortmentiq/)
- [Read Whitepaper](/ebooks-whitepapers/building-agentic-ai-chatbots-for-business-process-transformation/)
- [Listen Podcast](/events/podcast/how-jack-in-the-box-is-redefining-personalization-and-supply-chain-with-ai/)
- [Blogs](/blogs/)
- [White Papers](/ebooks-whitepapers/)
- [Case Studies](/case-studies/)
- [Podcast](/events/podcast/#Podcasts)
- [Read Blog](/blogs/the-genai-adoption-triad-responsibility-ethics-and-explainability/)
- [ConverseBot](/accelerators/#sales|conversebot/)
## Tags
- Data Management
---
## Footer Links
- [Talk to our AI experts](/contact-us/)
- [AI Strategy](/enterprise-ai-strategy/)
- [Agentic AI](/agentic-ai-solutions/)
- [Generative AI](/generative-ai/)
- [AI Managed Services](/ai-managed-services/)
- [Responsible AI](/responsible-ai-in-enterprise/)
- [Advanced Analytics](/advanced-data-analytics-solutions/)
- [Data Strategy](/data-analytics-strategy//)
- [Data Engineering](/data-engineering/)
- [Data Management](/ai-data-management-services/)
- [Cloud Transformation](/cloud-transformation/)
- [Data Ops](/data-devops/)
- [Data Visualization](/data-visualization-service/)
- [Automated Insights](/automated-insights/)
- [BI Migration](/bi-migration/)
- [Data Modeling](/data-modeling-services/)
- [Data Observability](/data-observability/)
- [CPG & Retail](/industries/cpg-analytics/)
- [Financial Services](/industries/banking-financial-analytics-services/)
- [Life Sciences](/industries/life-sciences/)
- [Case Studies](/case-studies/)
- [Thought Leadership](/ebooks-whitepapers/)
- [Blogs](/blogs/)
- [Company](/about-sigmoid/)
- [Newsroom](/newsroom/)
- [Accelerators](/accelerators/)
- [Careers](/careers/)
- [Privacy Policy |](/privacy-policy/)
- [Cookie Policy](/cookie-policy/)