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

    1. Run Once to Create Table (n8n-nodes-base.manualTrigger)
    2. Create Snapshot Table (n8n-nodes-base.postgres)
    3. Every Night at 2 (n8n-nodes-base.scheduleTrigger)
    4. Backup Settings (n8n-nodes-base.set)
    5. List Data Tables (n8n-nodes-base.dataTable)
    6. Any Tables? (n8n-nodes-base.if)
    7. Loop Over Tables (n8n-nodes-base.splitInBatches)
    8. Get All Rows (n8n-nodes-base.dataTable)
    9. Build Snapshot (n8n-nodes-base.code)
    10. Save Snapshot (n8n-nodes-base.postgres)
    11. Delete Expired Snapshots (n8n-nodes-base.postgres)
    12. Compare With Last Backup (n8n-nodes-base.postgres)
    13. Build Summary Email (n8n-nodes-base.code)
    14. Send Backup Summary (n8n-nodes-base.emailSend)
    15. Restore Form (n8n-nodes-base.formTrigger)
    16. Find Backup (n8n-nodes-base.postgres)
    17. Backup Found? (n8n-nodes-base.if)
    18. No Backup Found (n8n-nodes-base.form)
    19. Look Up Table by Name (n8n-nodes-base.dataTable)
    20. Match Table Name (n8n-nodes-base.code)
    21. Table Exists? (n8n-nodes-base.if)
    22. Table Not Found (n8n-nodes-base.form)
    23. Get Current Rows (n8n-nodes-base.dataTable)
    24. Build Safety Snapshot (n8n-nodes-base.code)
    25. Save Before-Restore Snapshot (n8n-nodes-base.postgres)
    26. Clear Current Rows (n8n-nodes-base.dataTable)
    27. Rows to Restore (n8n-nodes-base.code)
    28. Any Rows to Insert? (n8n-nodes-base.if)
    29. Insert Snapshot Rows (n8n-nodes-base.dataTable)
    30. Restore Complete (n8n-nodes-base.form)
    StickyNoteManualTriggerPostgresScheduleSetDataTableIFBatchCodeEmailSendFormTriggerForm
    34 nodesData Processing
    View on GitHub

    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.

    Related workflows