Automated Cloud Storage Cleanup with n8n
detail.loadingPreview
Streamline your cloud storage management with this n8n workflow. It automatically identifies and deletes files older than two weeks from your S3-compatible storage, sending timely notifications.
About This Workflow
This n8n workflow provides a robust solution for automating the cleanup of your cloud storage, specifically targeting S3-compatible services like Cloudflare R2. It begins by fetching all objects from a designated S3 bucket. A custom code step then intelligently filters these objects, identifying files that haven't been modified in over two weeks. These older files are subsequently deleted from the storage. To ensure transparency and operational awareness, a Telegram notification is sent upon successful deletion, confirming the removal of the targeted files. This workflow is ideal for managing data retention, optimizing storage costs, and maintaining a clean and organized cloud environment without manual intervention.
Key Features
- Automated File Deletion: Automatically removes files older than a specified retention period (e.g., 2 weeks).
- S3-Compatible Storage Integration: Seamlessly connects with S3-compatible storage services for fetching and deleting objects.
- Intelligent Filtering: Uses custom code to accurately identify and select files for deletion based on modification dates.
- Real-time Notifications: Sends Telegram alerts upon successful file cleanup, keeping you informed of automated operations.
- Scheduled Execution: Can be configured to run automatically on a daily schedule.
How To Use
- Schedule Trigger: Configure the
Schedule Triggernode to set the desired execution time for the workflow (e.g., daily at 9 AM). - S3 Node (Fetch All): Connect the
Schedule Triggerto the firstS3node. Configure theS3node with your Cloudflare R2 or other S3-compatible credentials, specifying yourbucketNameand thefolderKeyto target. - Code Node (Filter Files): Connect the first
S3node to theCodenode. The provided JavaScript code filters for files older than two weeks based on theirLastModifiedtimestamp. You can adjust theTWO_WEEKSconstant to define your desired retention period. - S3 Node (Delete): Connect the
Codenode to the secondS3node (namedS31). This node is configured to delete files. ThefileKeyis dynamically set using={{ $json.Key }}to target the files identified by theCodenode. - Telegram Node (Notify): Connect the
S31node to theTelegramnode. Configure this node with your Telegram API credentials andTELEGRAM_CHAT_ID. Thetextparameter is set to notify about the successful removal of files, including theKeyof the deleted file.
Apps Used
Workflow JSON
{
"id": "ffb60e26-f3b5-4987-a6be-1274d8b8b9c9",
"name": "Automated Cloud Storage Cleanup with n8n",
"nodes": 20,
"category": "DevOps",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: ffb60e26-f3b5...
About the Author
Free n8n Workflows Official
System Admin
The official repository for verified enterprise-grade workflows.
Statistics
Related Workflows
Discover more workflows you might like
Automated PR Merged QA Notifications
Streamline your QA process with this automated workflow that notifies your team upon successful Pull Request merges. Leverage AI and vector stores to enrich notifications and ensure seamless integration into your development pipeline.
Automate Qualys Report Generation and Retrieval
Streamline your Qualys security reporting by automating the generation and retrieval of reports. This workflow ensures timely access to crucial security data without manual intervention.
Visualize Your n8n Workflows: Interactive Dashboard with Mermaid.js
Gain unparalleled visibility into your n8n automation landscape. This workflow transforms your n8n instance into a dynamic, interactive dashboard, leveraging Mermaid.js to visualize all your workflows in one accessible place.