HeadlinesBriefing favicon HeadlinesBriefing.com

Automating n8n Workflow Backups to Google Drive

DEV Community •
×

A developer built an automated backup system for n8n workflows after accidentally deleting a 47-node workflow. The solution uses n8n's REST API to fetch all workflow definitions and the Google Drive API to upload them as timestamped JSON files, running on a six-hour schedule instead of real-time webhooks.

The architecture prioritizes lower API volume and cleaner audit history. It fetches workflows via the `/workflows` endpoint, converts each to binary, and uploads to a new Drive folder. Key decisions avoid complex webhook setups and direct database access, focusing on a simple, scheduled snapshot approach.

Critical gotchas include validating workflow data before conversion to prevent empty files, handling Google Drive rate limits (around 1,000 requests per 100 seconds), and managing binary data memory usage. The author also notes a restore edge case where missing credentials can break imports, recommending separate credential exports.

For production use, the setup requires an n8n instance with API access and a Google Drive OAuth2 credential. The full workflow configuration is available for those wanting to implement this backup strategy directly.