Automatic Gmail Attachment Backup to Google Drive - n8n Workflow

Use this efficient n8n workflow to automatically save email attachments from specific senders directly to Google Drive. A ready-to-use n8n template for reliable file backup.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Individuals and businesses who regularly receive important files via email.
Users looking for reliable, automated cloud backup solutions.
Developers seeking practical n8n templates for integrating email and cloud storage.
Anyone needing an advanced n8n workflow setup involving file binary data manipulation.

Overview

Managing file attachments manually can be time-consuming and prone to errors. This efficient n8n workflow solves that problem by providing a hands-off approach to backing up critical email files. By utilizing a continuous n8n trigger, the system monitors your inbox for emails originating from a specified sender. Once detected, the n8n node sequence automatically downloads the attachments and uploads them to a defined folder within Google Drive. This n8n template is essential for ensuring that important documents, invoices, or reports are saved instantly and securely, freeing up user bandwidth. It showcases advanced functionality, including binary data handling via a custom Code n8n node, making it a robust and versatile n8n workflow solution.

How it Works

The entire process is initiated by the Gmail Trigger n8n node, which acts as the starting point, polling your inbox at regular intervals (every minute) and filtering results based on a predefined sender address. Once a matching email is found, the Gmail n8n node retrieves the full message content and explicitly downloads all attached files. These attachments are initially processed as binary data. The key step involves the Code n8n node, which transforms the single input item (the email) containing multiple binary attachments into multiple individual items, ensuring the Google Drive n8n node can process each file separately. Finally, the Google Drive n8n node uploads each attachment to the configured destination folder, dynamically naming the file using the email ID and current timestamp to prevent conflicts. This robust n8n workflow concludes with a placeholder node ready for subsequent actions, like sending a confirmation notification.

Installation Guide


  1. Import the n8n Workflow: Copy the provided JSON data and import it into your n8n instance via the 'Workflows' menu.

  2. Configure Gmail Credentials: Update the credentials for both the 'Gmail Trigger' and 'Gmail' n8n node using your specific Gmail OAuth2 credentials. Ensure this account has the necessary permissions to read emails.

  3. Configure Google Drive Credentials: Update the credentials for the 'Google Drive' n8n node with your Google Drive OAuth2 credentials.

  4. Update Gmail Trigger: In the 'Gmail Trigger' n8n node, modify the 'Sender' filter under 'Filters' to match the email address you wish to monitor.

  5. Set Google Drive Destination: In the 'Google Drive' n8n node, update the folderId parameter to point to your desired backup destination folder.

  6. Activate: Ensure the n8n workflow is activated to begin continuous monitoring.

Node Details

Gmail Trigger: This essential n8n trigger node initiates the workflow. It is configured to run periodically, checking for new emails. Key configuration includes filtering incoming messages by a specific 'Sender' email address.
Gmail n8n Node: This node retrieves the full email message content based on the ID passed from the trigger. Critically, it uses the configuration Download Attachments: true to pull the raw binary files.
Code n8n Node: This custom scripting n8n node handles data transformation. It iterates over the binary attachments object received from the Gmail node and remaps each attachment into a separate item suitable for batch processing by the next node.
Google Drive n8n Node: This file operations n8n node handles the upload process. It uses the Input Data Field Name = data (referencing the mapped binary data) and is configured to upload to a specific folder ID (1aZmIqT9jG-...). It uses an expression for dynamic filename creation.


  • Replace Me (NoOp) n8n Node: A standard placeholder n8n node designed to be replaced or extended, typically used for adding post-upload logic such as Slack notifications or database logging.

Related n8n Workflows

Free

Nodes: 6 Nodes
Updated: December 26 2025
View all

Featured*