N8n Data Tables Daily Backup To Postgres
What this workflow does
The workflow contains these steps: Run Once to Create Table → Create Snapshot Table → Every Night at 2 → Backup Settings → List Data Tables → Any Tables? → Loop Over Tables → Get All Rows → Build Snapshot → Save Snapshot → Delete Expired Snapshots → Compare With Last Backup → Build Summary Email → Send Backup Summary → Restore Form → Find Backup → Backup Found? → No Backup Found → Look Up Table by Name → Match Table Name → Table Exists? → Table Not Found → Get Current Rows → Build Safety Snapshot → Save Before-Restore Snapshot → Clear Current Rows → Rows to Restore → Any Rows to Insert? → Insert Snapshot Rows → Restore Complete.
What you need
- An n8n instance to import and run the workflow.
- StickyNote access for the StickyNote steps listed in this workflow.
- ManualTrigger access for the ManualTrigger steps listed in this workflow.
- Postgres access for the Postgres steps listed in this workflow.
- Schedule access for the Schedule steps listed in this workflow.
- Set access for the Set steps listed in this workflow.
- DataTable access for the DataTable steps listed in this workflow.
- IF access for the IF steps listed in this workflow.
- Batch access for the Batch steps listed in this workflow.
- Code access for the Code steps listed in this workflow.
- EmailSend access for the EmailSend steps listed in this workflow.
- FormTrigger access for the FormTrigger steps listed in this workflow.
- Form access for the Form steps listed in this workflow.
Workflow nodes
- Run Once to Create Table (n8n-nodes-base.manualTrigger)
- Create Snapshot Table (n8n-nodes-base.postgres)
- Every Night at 2 (n8n-nodes-base.scheduleTrigger)
- Backup Settings (n8n-nodes-base.set)
- List Data Tables (n8n-nodes-base.dataTable)
- Any Tables? (n8n-nodes-base.if)
- Loop Over Tables (n8n-nodes-base.splitInBatches)
- Get All Rows (n8n-nodes-base.dataTable)
- Build Snapshot (n8n-nodes-base.code)
- Save Snapshot (n8n-nodes-base.postgres)
- Delete Expired Snapshots (n8n-nodes-base.postgres)
- Compare With Last Backup (n8n-nodes-base.postgres)
- Build Summary Email (n8n-nodes-base.code)
- Send Backup Summary (n8n-nodes-base.emailSend)
- Restore Form (n8n-nodes-base.formTrigger)
- Find Backup (n8n-nodes-base.postgres)
- Backup Found? (n8n-nodes-base.if)
- No Backup Found (n8n-nodes-base.form)
- Look Up Table by Name (n8n-nodes-base.dataTable)
- Match Table Name (n8n-nodes-base.code)
- Table Exists? (n8n-nodes-base.if)
- Table Not Found (n8n-nodes-base.form)
- Get Current Rows (n8n-nodes-base.dataTable)
- Build Safety Snapshot (n8n-nodes-base.code)
- Save Before-Restore Snapshot (n8n-nodes-base.postgres)
- Clear Current Rows (n8n-nodes-base.dataTable)
- Rows to Restore (n8n-nodes-base.code)
- Any Rows to Insert? (n8n-nodes-base.if)
- Insert Snapshot Rows (n8n-nodes-base.dataTable)
- Restore Complete (n8n-nodes-base.form)
Need this workflow customized or debugged? Book a 30-min scope call →
Want this set up for you? Book a 30-min scope call
I build and fix n8n workflows for agencies and SaaS teams. 30-minute scope call — bring the problem, leave with an estimate.