This n8n workflow automatically backs up email attachments from a specific sender in Gmail to a designated folder in Google Drive. It polls Gmail every minute and uploads any new attachments from matching emails to the specified Google Drive folder with a timestamped filename.
Primary Purpose:
[email protected]
) to Google Drive for safekeeping, audit, or processing.Ideal For:
Here’s how the workflow operates:
🔔 Gmail Trigger
Polls Gmail every minute for new messages from a specific sender ([email protected]
).
📩 Gmail Get Message
Retrieves the full contents (including attachments) of the matched email.
🧠 Code (JS)
Iterates over all binary attachments in the email and restructures them as individual binary items to upload separately.
📤 Google Drive
Uploads each attachment to a target Google Drive folder (DOcs
) with a timestamp and unique name.
📍 Replace Me (NoOp)
Placeholder node to indicate workflow completion. You can replace this with Slack notifications, logs, or alerts.
Import the Workflow
Copy and paste the workflow JSON into your n8n editor.
Set Up Credentials
Ensure the following credentials exist and are authorized:
Configure the Folder
Update the folderId
in the Google Drive node if you want to use a different target folder.
Activate the Workflow
Enable the workflow in n8n. It will start polling Gmail every minute.
Task | How to Customize |
---|---|
Change sender filter | Modify the sender field in the Gmail Trigger node |
Adjust polling frequency | Change the pollTimes configuration in the trigger node |
Change destination folder | Update folderId in the Google Drive node |
Modify filename format | Edit the name expression in the Google Drive node |
Add post-upload logic | Replace or extend the Replace Me node with notifications, logs, etc. |
Process only specific attachments | Add logic in the Code node to filter by filename or MIME type |
[MessageID]_[Timestamp]_backup_attachment
This naming convention ensures uniqueness and traceability back to the original message.
For any issues using this workflow: