AutomationFlowsSlack & Telegram › Auto-cleanup of Cloudflare R2 Files Older Than 2 Weeks (+ Telegram…

Auto-cleanup of Cloudflare R2 Files Older Than 2 Weeks (+ Telegram…

Original n8n title: Auto-cleanup of Cloudflare R2 Files Older Than 2 Weeks (+ Telegram Notifications)

ByMobder @mobder on n8n.io

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.

Cron / scheduled trigger★★★★☆ complexity10 nodesS3Telegram
Slack & Telegram Trigger: Cron / scheduled Nodes: 10 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #4418 — we link there as the canonical source.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "1d6e7f05-a102-47aa-adf7-a5c99fd6de24",
      "name": "S3",
      "type": "n8n-nodes-base.s3",
      "position": [
        -140,
        -80
      ],
      "parameters": {
        "options": {
          "folderKey": "Folder/",
          "fetchOwner": false
        },
        "operation": "getAll",
        "returnAll": true,
        "bucketName": "bucketName"
      },
      "credentials": {
        "s3": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": false,
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "bbc59eb2-b927-48ae-9b05-9dde8f8bb076",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        140,
        -80
      ],
      "parameters": {
        "jsCode": "const TWO_WEEKS = 14 * 24 * 60 * 60 * 1000;\nconst now = Date.now();\nconst today = new Date().toISOString().split(\"T\")[0]; // YYYY-MM-DD\n\nconst items = $items(\"S3\", 0); // \u0e14\u0e36\u0e07\u0e44\u0e1f\u0e25\u0e4c\u0e17\u0e31\u0e49\u0e07\u0e2b\u0e21\u0e14\u0e08\u0e32\u0e01 AWS S3 Node\n\nreturn items.filter(item => {\n   const lastModified = new Date(item.json.LastModified).getTime();\n  const age = now - lastModified;\n  return age > TWO_WEEKS;\n  // const fileDate = new Date(item.json.LastModified).toISOString().split(\"T\")[0];\n  // return fileDate === today;\n});\n\n"
      },
      "typeVersion": 2
    },
    {
      "id": "0612b8b7-23e1-4ccc-8563-3e2396f67c6d",
      "name": "S31",
      "type": "n8n-nodes-base.s3",
      "position": [
        420,
        -80
      ],
      "parameters": {
        "fileKey": "={{ $json.Key }}",
        "options": {},
        "operation": "delete",
        "bucketName": "bucketName"
      },
      "credentials": {
        "s3": {
          "name": "<your credential>"
        }
      },
      "executeOnce": false,
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "0864095d-e7eb-47d3-9b21-2103b6f64a01",
      "name": "Telegram",
      "type": "n8n-nodes-base.telegram",
      "position": [
        680,
        -80
      ],
      "parameters": {
        "text": "=\u2705 Remove R2 backup complete  \n\ud83d\udc4c*{{ $('Code').item.json.Key }}*",
        "chatId": "TELEGRAM_CHAT_ID",
        "additionalFields": {}
      },
      "credentials": {
        "telegramApi": {
          "name": "<your credential>"
        }
      },
      "executeOnce": false,
      "typeVersion": 1.2
    },
    {
      "id": "808e756e-7a74-4b03-86ac-c915578a7c04",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -400,
        -80
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "86406c94-fa65-446c-aad9-47cd6073e61d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -460,
        -240
      ],
      "parameters": {
        "height": 340,
        "content": "## Schedul\nRun from setup schedule time"
      },
      "typeVersion": 1
    },
    {
      "id": "a8fc923d-623b-4d68-8896-d97411d8be10",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -200,
        -240
      ],
      "parameters": {
        "color": 5,
        "width": 220,
        "height": 340,
        "content": "## R2 Object (S3)\nGet file from Cloudflare R2 Object (S3)"
      },
      "typeVersion": 1
    },
    {
      "id": "3db54850-3f7c-4638-ae04-4110efeb69d0",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        60,
        -240
      ],
      "parameters": {
        "color": 6,
        "width": 260,
        "height": 340,
        "content": "## Filter File\nFilter file for remove"
      },
      "typeVersion": 1
    },
    {
      "id": "8814b537-f0e0-4e18-a1b3-9a43beae7f72",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        340,
        -240
      ],
      "parameters": {
        "color": 5,
        "height": 340,
        "content": "## Delete File\nRemove file from cloud"
      },
      "typeVersion": 1
    },
    {
      "id": "1442dabd-cfb8-4c79-8ff3-c53d6f06009f",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        620,
        -240
      ],
      "parameters": {
        "color": 5,
        "height": 340,
        "content": "## Telegram Notify\nNotify remove file success"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "S3": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "S31": {
      "main": [
        [
          {
            "node": "Telegram",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "S31",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "S3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

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.

Source: https://n8n.io/workflows/4418/ — original creator credit. Request a take-down →

More Slack & Telegram workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

Slack & Telegram

Solo founders and spreadsheet gremlins who track everything in Notion and want crisp Telegram pings without opening a single page.

Telegram, Notion
Slack & Telegram

A robust workflow to back up and synchronize your n8n workflows to a GitHub repository, with intelligent change detection and support for file renames.

GitHub, n8n, Telegram +1
Slack & Telegram

[](https://www.linkedin.com/in/mosaab-yassir-lafrimi/)[](https://t.me/joevenner)

HTTP Request, Redis, S3 +1
Slack & Telegram

With the increasing popularity of stablecoins like USDC, its becoming easier to pay for everyday items with crypto thanks to debit cards from issuers like MetaMask. These solutions work by processing

Telegram, N8N Nodes 1Shot
Slack & Telegram

This workflow continuously monitors the TikTok Ads Library for new creatives from specific advertisers or keyword searches, scrapes them via Apify, logs them into Google Sheets, and sends concise noti

Google Sheets, Slack, Telegram +1