1. Opening Problem Statement
Meet Sarah, a workflow developer who manages dozens of complex n8n workflows for her company’s daily automation needs. Every day, Sarah fears losing her carefully built workflows due to unexpected errors or accidental deletions. The manual backup process she used before was tedious and error-prone, taking up to hours each week and leaving gaps in backup consistency. Without a reliable automated backup system, Sarah risks losing valuable configurations, causing downtime and lost productivity for her entire team.
This workflow specifically solves Sarah’s challenges by fully automating the backup of n8n workflows, saving them as JSON files in organized, date-stamped Google Drive folders. It also keeps her cloud storage tidy by automatically deleting backup folders older than seven days. With Telegram notifications, Sarah never misses a backup status update, giving her peace of mind that her workflows are secure and recoverable.
2. What This Automation Does
This workflow leverages n8n nodes to:
- Trigger backups either manually or on a daily schedule using Manual Trigger and Schedule Trigger nodes.
- Create a new Google Drive folder for each backup with a current timestamp for easy identification.
- Retrieve all n8n workflows via the n8n API node, limited to 200 workflows to handle large accounts.
- Convert each workflow into a JSON file format ready for backup storage.
- Upload workflow JSON files into the newly created Google Drive folder.
- Search existing backup folders to find and delete those older than seven days, keeping storage optimized.
- Notify users through Telegram with a message including the backup completion time and drive folder link.
This automation saves Sarah hours every week, eliminates manual backup errors, organizes backups systematically, and keeps her informed—all automatically.
3. Prerequisites ⚙️
- n8n account with access to create workflows.
- Google Drive account with OAuth2 credentials set up in n8n for file and folder operations.
- n8n API access credentials to fetch workflows programmatically.
- Telegram bot credentials including chat ID for sending notifications.
- Basic familiarity with n8n workflow building.
4. Step-by-Step Guide
Step 1: Set Up the Trigger Nodes
In n8n, start by adding two trigger nodes: Manual Trigger (named “On clicking ‘execute'”) and Schedule Trigger (named “Every Day”). Configure the Schedule Trigger to run daily at your preferred time (default is every 24 hours). This allows you to run backups either on demand or automatically.
Step 2: Get the Current DateTime Stamp
Add a Set node named “Get DateTime” where you set a variable datetime to {{ $now }} which captures the precise timestamp for folder naming. This ensures each backup folder has a unique, chronological name.
Step 3: Create Google Drive Folder with Timestamp
Use a Google Drive node configured as Folder creation and set the name parameter to a template like n8n-Workflow-Backups-{{ $json.datetime }}. This will create a new folder in your Drive root folder named for the backup date and time.
Step 4: Retrieve All Workflows from n8n
Add the n8n node “Get Workflows” to fetch workflows via the n8n API. Limit to 200 workflows if you have many for performance. This node requests all your current workflow data.
Step 5: Limit Workflow Count for Processing
Next, place a Limit node with maxItems set to 200 to restrict processing. This prevents workflow overload and keeps backups manageable.
Step 6: Split Workflows into Batches
Add the SplitInBatches node named “Loop Over Items” to process each workflow individually. Disable batch reset to ensure continuous processing.
Step 7: Convert Each Workflow to JSON File
Insert the ConvertToFile node with operation set to “toJson”. Use {{ $json.name }} as the file name template. This converts each workflow item into a downloadable JSON file.
Step 8: Save JSON Files to Created Google Drive Folder
Use another Google Drive node set to upload each JSON file. Use the folder ID from the earlier created folder to place backups neatly inside the date folder. The file name is dynamically assigned from the JSON data.
Step 9: Search Existing Backup Folders in Google Drive
Use a Google Drive node to search for folders with names like n8n-Workflow-Backups. Limit the search to 10 folders max. This prepares for cleanup of older backups.
Step 10: Identify Old Backup Folders to Delete
Use a Code node named “Find Folders to Delete” with JavaScript to sort folders by name descending and select folders older than the last seven days. Here’s the code snippet:
// Get all input items and sort by name in descending order
const sortedItems = $input.all().sort((a, b) => {
if (!a.name || !b.name) return 0;
return b.name.localeCompare(a.name);
});
// Get items older than 7 days
const olderItems = sortedItems.slice(7);
return olderItems
Step 11: Delete Old Backup Folders
Connect a Google Drive node in delete folder mode. Use the folder IDs from the Code node output. Set deletePermanently to true to ensure folders are fully removed, freeing up Drive space.
Step 12: Send Completion Notification via Telegram
Add a Telegram node with your bot credentials. Configure the message to include the current timestamp, the backup folder name, and a direct Google Drive link. You can use this message template:
{{ $now }}
Workflows Backup Complete
{{ $('Create Folder with DateTime Stamp').item.json.name }}
https://drive.google.com/drive/folders/{{ $('Create Folder with DateTime Stamp').item.json.id }}
Set the chat ID dynamically from environment variables for security.
5. Customizations ✏️
- Adjust Backup Frequency: Modify the “Every Day” Schedule Trigger node to run at different intervals, such as hourly or weekly.
- Change Retention Period: In the Code node “Find Folders to Delete,” change
slice(7)toslice(N)where N is the number of backup days you want to keep. - Customize Folder Naming: Modify the Folder creation node’s
namefield to include time or other variables alongside the date. - Enhance Notifications: Edit the Telegram node to include additional info such as backup size or number of workflows backed up.
- Manual Trigger Only Mode: If you prefer manual backups only, disable the Schedule Trigger node by removing its connections.
6. Troubleshooting 🔧
Problem: “Google Drive folder creation fails with authentication error.”
Cause: OAuth2 credentials for Google Drive are missing, expired, or incorrectly configured.
Solution: Go to n8n credentials, refresh or set up Google Drive OAuth2 credentials properly. Re-authenticate if necessary.
Problem: “No workflows appear in the ‘Get Workflows’ node.”
Cause: Incorrect or missing n8n API credentials or insufficient API permissions.
Solution: Verify API credentials and ensure n8n instance is accessible. Test API outside n8n if needed.
Problem: “Telegram notifications do not appear after backup completes.”
Cause: Telegram bot token or chat ID environment variable is incorrect or missing.
Solution: Check Telegram credentials setup in n8n. Confirm chat ID environment variable is correct and accessible.
7. Pre-Production Checklist ✅
- Verify Google Drive OAuth2 credentials are valid and have sufficient permissions.
- Confirm n8n API credentials work and workflows are accessible.
- Set environment variable for Telegram chat ID correctly.
- Test manual trigger and view created folders and files in Google Drive.
- Run schedule trigger and confirm backups execute as expected.
- Check old backups are pruned after seven days.
- Validate Telegram notification message receipt.
- Backup your n8n workflow export to a safe location before deploying automated backups.
8. Deployment Guide
Activate this workflow by toggling it on in n8n. Ensure the Schedule Trigger node is active for daily automated runs. Monitor initial runs manually through workflow executions in n8n. Enable error alerts in n8n to catch any issues during backups. Maintain Telegram notifications for live status updates. Periodically review Google Drive to ensure backups are saved and old ones pruned as expected.
9. FAQs
- Q: Can I use Dropbox instead of Google Drive?
A: This workflow is designed with Google Drive nodes. To use Dropbox, you’d need to replace Google Drive nodes with Dropbox equivalents and adjust authentication accordingly. - Q: Does this consume n8n API credits or cost extra?
A: Accessing your n8n workflows via the API does not consume credits beyond your n8n usage limits. Google Drive and Telegram usage depend on their own quotas. - Q: Is my backup data secure?
A: All data transfers occur through secure OAuth2 authentication and encrypted API calls. Ensure your Google Drive account has strong security settings. - Q: Can this handle hundreds of workflows?
A: The workflow limits processing to 200 workflows to keep performance stable. For larger setups, consider running multiple backup workflows or adjusting limits.
10. Conclusion
By implementing this automation, you have effectively set up a robust n8n workflow backup system that saves your workflows daily as JSON files in Google Drive with neat timestamped folders. You’ve also automated the cleanup of old backups to manage storage and receive real-time Telegram notifications on backup status.
This saves significant time and prevents workflow loss due to errors or accidental deletions, empowering you to focus on building more automations instead of worrying about data safety.
For next steps, consider automating workflow deployment, integrating backup encryption for added security, or expanding notifications to Slack or email for team alerts.
Keep building and automating — your workflows are now safer than ever!