๐Ÿ“ Auto-cleanup of Cloudflare R2 files older than 2 weeks (+ Telegram notifications)

โšก 549 views ยท ๐Ÿ“ File Management

Description

This workflow automatically connects to a Cloudflare R2 bucket (via S3-compatible API), filters out files older than 14 days, deletes them, and then sends a Telegram notification for each deletion. It runs on a daily schedule.

๐Ÿ•˜ Schedule Trigger Executes the workflow once a day at a specified hour (e.g., 9 AM).

๐Ÿ“ฆ S3 Node โ€“ List Files Retrieves all objects from a specific folder (prefix) in a Cloudflare R2 bucket using the S3 API.

๐Ÿ”Ž Code Node โ€“ Filter Files Older Than 2 Weeks Filters the retrieved files by comparing their LastModified timestamps to the current date. Files older than 14 days (2 weeks) are selected for deletion.

๐Ÿ—‘๏ธ S3 Node โ€“ Delete File Deletes each filtered file from the R2 bucket.

๐Ÿ“จ Telegram Node โ€“ Notify Deletion Sends a Telegram message with the name of the deleted file to a specified chat ID. The message includes:

๐Ÿ”— Nodes Used

Telegram, S3, Schedule Trigger

๐Ÿ“ฅ Import

Download workflow.json and import into n8n: Workflow menu โ†’ Import from File

๐Ÿ“– Importing guide ยท ๐Ÿ”‘ Credential setup