n8n Scheduled Data Export: Cron, CSV, and Auto-Cleanup
Build an n8n scheduled data export workflow: cron-trigger a source read, write timestamped CSV, store it, prune old files, and alert when an export fails.
Exports are the kind of automation nobody thinks about until the storage bill spikes or someone asks for "last Tuesday's data" and it's gone. An n8n scheduled data export turns the recurring "pull the rows, save a file, stash it somewhere" chore into a cron job. But the version worth running does three things the popular templates don't: it works for any source, it timestamps for versioning, and it prunes itself so the folder doesn't grow without limit.
Search this and you mostly find Sheets-to-Drive backups or workflow-JSON backups. Those are useful, narrow tools. The general pattern (read any source, write a dated file, store it, clean up the old ones, alert on failure) is the one this post builds, and it's distinct from the instance backup workflow that snapshots n8n itself.
What you can export on a schedule
The same shape covers most recurring export needs:
- A Postgres or MySQL table dumped nightly for an analyst
- A Google Sheet snapshotted weekly for an audit trail
- An API's data pulled daily and archived as JSON
- A filtered slice of a CRM exported for a partner
- Yesterday's orders shipped as a CSV to finance
- Any "email me the data every Monday" standing request
The Scheduled Export Pipeline
Schedule (cron) → Read source → Convert to File (CSV) → Name with timestamp → Store
│
Prune old files
│
Alert on failure
The two steps after "store" are what most templates leave out, and they're the ones that keep the workflow healthy long-term.
1. Trigger on a real cron
Use the Schedule trigger with a cron expression, not a fixed interval, when timing matters. 0 6 * * * runs at 6am daily; 0 7 * * 1 runs Monday at 7am. One caveat worth internalizing: a Schedule trigger set to a tight interval will silently drop a run if the previous execution is still in flight. For heavy exports, give the cron enough headroom that one run finishes before the next starts.
2. Read the source
This is where the general pattern beats the Sheets-only templates. Swap the read node to match the source: Postgres or MySQL with a SELECT, Google Sheets for a tab, HTTP Request for an API. The rest of the pipeline doesn't care where the rows came from.
-- example: yesterday's orders
SELECT id, customer_email, amount, created_at
FROM orders
WHERE created_at >= NOW() - INTERVAL '1 day';
3. Convert to a file
The Convert to File node turns the items into a CSV (or XLSX, or JSON) binary. Pick the format your consumer actually wants; finance usually wants CSV, a data team might prefer JSON. Set the delimiter explicitly; a European consumer opening a comma-CSV in a semicolon locale gets one mangled column.
4. Name it for versioning
A file called export.csv overwrites itself every run, which defeats the point of a history. Stamp the name with the date so each run is a distinct, restorable snapshot:
const date = new Date().toISOString().slice(0, 10);
return [{ json: { filename: `orders_export_${date}.csv` }, binary: $binary }];
Now orders_export_2026-06-14.csv sits beside last week's, and "give me last Tuesday's data" is a folder lookup.
5. Store and prune
Upload to Google Drive, S3, or wherever the archive lives. Then comes the step nearly every template skips: prune. Without retention, the export folder grows forever until it's a storage problem or an audit liability. List the folder, filter files older than your window, delete the rest:
const keepDays = 90;
const cutoff = Date.now() - keepDays * 864e5;
return items.filter(({ json }) => new Date(json.createdTime).getTime() < cutoff);
The opinionated take: an export workflow without a retention policy is half-built. Storage is cheap right up until it isn't, and an unbounded archive of customer data is a compliance question waiting to be asked. Decide the window when you build it, not after the bill arrives.
A scheduled export that writes to a fixed filename overwrites yesterday's snapshot every single run. You end up with exactly one file and no history, which is not a backup, it's a live mirror. Put the date in the filename so each run is its own restorable point, then pair it with a retention prune so the folder doesn't grow forever.
Implementation patterns
Pattern 1: Nightly table dump. Cron at 2am, SELECT the table, Convert to File, upload with a dated name, prune past 90 days. The workhorse pattern.
Pattern 2: Weekly stakeholder export. Monday cron, read a filtered slice, email the CSV as an attachment so the recipient never logs in. Lighter retention since the file also lives in their inbox.
Pattern 3: Multi-format archive. Convert the same data to both CSV and JSON, store each in its own folder. Costs one extra node, serves two consumers. The scheduling mechanics here mirror the scheduled tasks and cron guide.
n8n nodes you'll use most
| Node | Purpose |
|---|---|
| Schedule | Fires the export on a cron cadence |
| Postgres / Google Sheets / HTTP Request | Reads the source data |
| Convert to File | Turns rows into a CSV, XLSX, or JSON binary |
| Code | Builds the timestamped filename and the prune filter |
| Google Drive / S3 | Stores the export and lists files for cleanup |
| Send Email / Slack | Alerts when the export fails |
Getting started
- Add a Schedule trigger with the cron expression for your cadence.
- Add the read node matching your source and write the query or range.
- Add a Convert to File node and pick CSV, XLSX, or JSON.
- Build a timestamped filename in a Code node.
- Upload to your storage of choice.
- Add a prune step that deletes files past your retention window.
- Add a failure branch that alerts you, then run once and check the file lands.
Assembling the read, convert, timestamp, store, and prune chain for each new source gets repetitive. A dashboard template that already reads a source on a schedule and ships a formatted output is a faster on-ramp.
The Decision-Maker's Weekly Dashboard runs this scheduled-read-and-deliver pattern on a cron: it reads a Google Sheet every Monday, formats the data, and delivers it to an inbox automatically, so you adapt the read and output steps instead of wiring the schedule from scratch. It's part of The Complete n8n Templates Bundle, a one-time lifetime license to the whole catalog and every future template, worth it once you're running more than one scheduled job.
A scheduled export that versions its files and cleans up after itself is the unglamorous backbone of a data team's trust in its own archive. Set the cron, stamp the date, prune the old ones, and the "where's last week's data?" question answers itself. Next, automate the inbound side with the webhook to database workflow, or feed the exported data into a live view with the KPI dashboard automation. The App Analytics Dashboard shows the same scheduled-read-and-log pattern against a live GA4 source. Browse the rest of the reporting templates when the exports are humming.
Browse the template catalog →Common questions
How do I schedule a data export in n8n?
Can n8n export a database table to CSV automatically?
How do I stop old export files from piling up?
Get the workflow templates this guide is built on
Import-ready n8n JSON, step-by-step setup, and tested end-to-end. One-time payment, own it forever.
Get 3 tested n8n templates, free
The full customer package for three real catalog templates — workflow JSON, step-by-step setup guide, credential checklist. Built through the same live-instance release process as everything we sell. Plus new templates and automation guides in your inbox. No spam, unsubscribe anytime.
- 01Smart To-Do List ManagerPre-built n8n workflow template that automates productivity with OpenAI. Live in about 10 minutes.$14
- 02Email Follow-Up AutomatorPre-built n8n workflow template that automates crm with OpenAI. Live in about 15 minutes.$12
- 03Market Trend AnalyzerPre-built n8n workflow template that automates data processing with OpenAI. Live in about 10 minutes.$14
More automation guides

How to Build n8n Decision Support Automation with AI Frameworks
A founder spends a week circling a pricing decision. Not because the information's missing. It's all there. The hold-up is that there's no process to run it through. The pros and cons live in three ha…

How to Build n8n Employee Wellness Automation with AI Risk Scoring
Two people resign in the same month, both citing burnout. Nothing in the 1:1 notes flagged it. Nothing in their Slack activity looked off. The signals were there, in the throwaway comments, the slippi…

How to Build n8n Approval Workflow Automation That Auto-Approves and Escalates
A finance lead approves the same refunds every morning. Under $100, customer in good standing, clear reason. Approved, approved, approved. The decision was never hard. It just never got automated, so…