Automated Google Drive to FTP Transfer with JSON Logging & Reports
Google Drive to FTP Transfer Workflow - Setup Guide
Overview
This n8n workflow automatically transfers files from Google Drive to an FTP server on a scheduled basis. It includes comprehensive logging, email notifications, and error handling.
Features
Automated Scheduling**: Runs every 6 hours (customizable) Manual Trigger**: Webhook endpoint for on-demand transfers File Filtering**: Supports specific file types and size limits Comprehensive Logging**: Detailed transfer reports saved to Google Drive Email Notifications**: HTML reports sent after each run Error Handling**: Graceful handling of failed transfers Batch Processing**: Files processed individually to prevent rate limits
Prerequisites
Before setting up this workflow, ensure you have:
n8n instance running (self-hosted or cloud) Google Drive account with files to transfer FTP server with upload permissions Email service for sending reports (SMTP)
Step-by-Step Setup Instructions
- Google Drive API Setup
1.1 Create Google Cloud Project Go to Google Cloud Console Create a new project or select existing one Enable the Google Drive API: Navigate to "APIs & Services" → "Library" Search for "Google Drive API" Click "Enable"
1.2 Create OAuth2 Credentials Go to "APIs & Services" → "Credentials" Click "Create Credentials" → "OAuth client ID" Configure consent screen if prompted Choose "Web application" as application type Add your n8n instance URL to authorized redirect URIs: https://your-n8n-instance.com/rest/oauth2-credential/callback Note down the Client ID and Client Secret
1.3 Configure n8n Credential In n8n, go to "Credentials" → "Add Credential" Select "Google Drive OAuth2 API" Enter your Client ID and Client Secret Complete OAuth flow by clicking "Connect my account" Set credential ID as: your-google-drive-credentials-id
- FTP Server Setup
2.1 FTP Server Requirements Ensure FTP server is accessible from your n8n instance Verify you have upload permissions Note the server details: Host/IP address Port (usually 21 for FTP) Username and password Destination directory path
2.2 Configure n8n FTP Credential In n8n, go to "Credentials" → "Add Credential" Select "FTP" Enter your FTP server details: Host: your-ftp-server.com Port: 21 (or your custom port) Username: your-ftp-username Password: your-ftp-password Set credential ID as: your-ftp-credentials-id
- Email Setup (SMTP)
3.1 Choose Email Provider Configure SMTP settings for one of these providers: Gmail**: smtp.gmail.com, port 587, use App Password Outlook**: smtp-mail.outlook.com, port 587 Custom SMTP**: Your organization's SMTP server
3.2 Configure n8n Email Credential In n8n, go to "Credentials" → "Add Credential" Select "SMTP" Enter your SMTP details: Host: smtp.gmail.com (or your provider) Port: 587 Security: STARTTLS Username: your-email@example.com Password: your-app-password Set credential ID as: your-email-credentials-id
- Workflow Configuration
4.1 Import Workflow Copy the workflow JSON from the artifact above In n8n, click "Import from JSON" Paste the workflow JSON and import
4.2 Update Credential References Google Drive nodes: Verify credential ID matches your-google-drive-credentials-id FTP node: Verify credential ID matches your-ftp-credentials-id Email node: Verify credential ID matches your-email-credentials-id
4.3 Customize Parameters
FTP Server Settings (Upload to FTP node) { "host": "your-ftp-server.com", // Replace with your FTP host "username": "your-ftp-username", // Replace with your FTP username "password": "your-ftp-password", // Replace with your FTP password "path": "/remote/directory/{{ $json.validFiles[$json.batchIndex].name }}", // Update destination path "port": 21 // Change if using different port }
Email Settings (Send Report Email node) { "sendTo": "admin@yourcompany.com", // Replace with your email address "subject": "Google Drive to FTP File Transfer - Report" }
File Filter Settings (Filter & Validate Files node) In the JavaScript code, update these settings: const transferNotes = { settings: { maxFileSizeMB: 50, // Change maximum file size allowedExtensions: [ // Add/remove allowed file types '.pdf', '.doc', '.docx', '.txt', '.jpg', '.png', '.zip', '.xlsx' ], autoDeleteAfterTransfer: false, // Set to true to delete from Drive after transfer verifyTransfer: true // Keep true for verification } };
Google Drive Notes Storage (Upload Notes to Drive node) { "parents": { "parentId": "your-notes-folder-id" // Replace with actual folder ID from Google Drive } }
- Schedule Configuration
5.1 Modify Schedule Trigger In the "Schedule Trigger" node, adjust the interval: { "rule": { "interval": [ { "field": "hours", "hoursInterval": 6 // Change to desired interval (hours) } ] } }
Alternative schedule options: Daily**: "field": "days", "daysInterval": 1 Weekly**: "field": "weeks", "weeksInterval": 1 Custom cron**: Use cron expression for complex schedules
5.2 Webhook Configuration The webhook trigger is available at: POST https://your-n8n-instance.com/webhook/webhook-transfer-status
Use this for manual triggers or external integrations.
- Testing and Validation
6.1 Test Connections Test Google Drive: Run "Get Drive Files" node manually Test FTP: Upload a test file using "Upload to FTP" node Test Email: Send a test email using "Send Report Email" node
6.2 Run Test Transfer Activate the workflow Click "Execute Workflow" to run manually Monitor execution in the workflow editor Check for any error messages or failed nodes
6.3 Verify Results FTP Server**: Confirm files appear in destination directory Email**: Check you receive the transfer report Google Drive**: Verify transfer notes are saved to specified folder
- Monitoring and Maintenance
7.1 Workflow Monitoring Execution History**: Review past runs in n8n interface Error Logs**: Check failed executions for issues Performance**: Monitor execution times and resource usage
7.2 Regular Maintenance Credential Renewal**: Google OAuth tokens may need periodic renewal Storage Cleanup**: Consider archiving old transfer notes Performance Tuning**: Adjust batch sizes or schedules based on usage
- Troubleshooting
8.1 Common Issues
Google Drive Authentication Errors: Verify OAuth2 credentials are correctly configured Check if Google Drive API is enabled Ensure redirect URI matches n8n instance URL
FTP Connection Failures: Verify FTP server credentials and connectivity Check firewall settings allow FTP connections Confirm destination directory exists and has write permissions
Email Delivery Issues: Verify SMTP credentials and server settings Check if email provider requires app-specific passwords Ensure sender email is authorized
File Transfer Failures: Check file size limits in filter settings Verify allowed file extensions include your file types Monitor FTP server disk space
8.2 Debug Mode Enable debug mode by: Adding console.log statements in code nodes Using "Execute Workflow" with step-by-step execution Checking node outputs for data validation
- Advanced Customizations
9.1 Additional File Filters Add custom filtering logic in the "Filter & Validate Files" node: // Example: Filter by modification date const isRecentFile = new Date(file.modifiedTime) > new Date(Date.now() - 7 * 24 * 60 * 60 * 1000); // Last 7 days
// Example: Filter by folder location const isInSpecificFolder = file.parents && file.parents.includes('specific-folder-id');
9.2 Enhanced Reporting Customize the email report template in "Send Report Email" node: 📊 File Transfer Report
Summary
Date: {{ new Date().toLocaleString('en-US') }}
Success Rate: {{ Math.round((successfulTransfers / totalFiles) * 100) }}%
9.3 Integration with Other Services Add nodes to integrate with: Slack**: Send notifications to team channels Discord**: Post updates to Discord servers Webhook**: Trigger other workflows or systems Database**: Log transfers to MySQL, PostgreSQL, etc.
- Security Considerations
10.1 Credential Security Use environment variables for sensitive data Regularly rotate FTP and email passwords Implement least-privilege access for service accounts
10.2 Network Security Use SFTP instead of FTP when possible Implement VPN connections for sensitive transfers Monitor network traffic for unusual patterns
10.3 Data Privacy Ensure compliance with data protection regulations Implement data retention policies for transfer logs Consider encryption for sensitive file transfers
Support and Resources
Documentation Links n8n Documentation Google Drive API Documentation n8n Community Forum
Getting Help If you encounter issues: Check the troubleshooting section above Review n8n execution logs for error details Search the n8n community forum for similar issues Create a support ticket with detailed error information
Note: Replace all placeholder values (URLs, credentials, IDs) with your actual configuration before running the workflow.
Related Templates
Instagram Full Profile Scraper with Apify and Google Sheets
📸 Instagram Full Profile Scraper with Apify and Google Sheets This n8n workflow automates the process of scraping ful...
Generate Product Ad Copy & CTAs with GPT-4 for Slack and Airtable
⚡ AI Copywriter Pro: Instant Ad Copy & CTA Generator Transform product details into compelling marketing copy in second...
Technology News Workflow Explanation with Key Services
This workflow contains community nodes that are only compatible with the self-hosted version of n8n. Auto-Publish Techn...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments