๐Ÿ“ Automated FTP file migration with smart cleanup and email notifications

โšก 226 views ยท ๐Ÿ“ File Management

Description

Automated FTP File Migration with Smart Cleanup and Email Notifications

Overview

This n8n workflow automates the secure transfer of files between FTP servers on a scheduled basis, providing enterprise-grade reliability with comprehensive error handling and dual notification systems (email + webhook). Perfect for data migrations, automated backups, and multi-server file synchronization.

What it does

This workflow automatically discovers, filters, transfers, and safely removes files between FTP servers while maintaining complete audit trails and sending detailed notifications about every operation.

Key Features:

Use Cases

๐Ÿข Enterprise & IT Operations

๐Ÿ“Š Business Operations

๐Ÿ”ง Development & DevOps

How it works

๐Ÿ“‹ Workflow Steps

  1. Schedule Trigger โ†’ Initiates workflow at specified intervals
  2. File Discovery โ†’ Lists files from source FTP server with optional recursion
  3. Smart Filtering โ†’ Applies customizable filters (type, size, date, name patterns)
  4. Secure Download โ†’ Retrieves files to temporary n8n storage with retry logic
  5. Safe Upload โ†’ Transfers files to destination with directory auto-creation
  6. Transfer Validation โ†’ Verifies successful upload before proceeding
  7. Source Cleanup โ†’ Removes original files only after confirmed success
  8. Comprehensive Logging โ†’ Records all operations with detailed metadata
  9. Dual Notifications โ†’ Sends email + webhook notifications for success/failure

๐Ÿ”„ Error Handling Flow

Setup Requirements

๐Ÿ”‘ Credentials Needed

  1. Source FTP Server

    • Host, port, username, password
    • Read permissions required
    • SFTP recommended for security
  2. Destination FTP Server

    • Host, port, username, password
    • Write permissions required
    • Directory creation permissions
  3. SMTP Email Server

    • SMTP host and port (e.g., smtp.gmail.com:587)
    • Authentication credentials
    • For success and error notifications
  4. Monitoring API (Optional)

    • Webhook URL for system integration
    • Authentication tokens if required

โš™๏ธ Configuration Steps

  1. Import Workflow โ†’ Load the JSON template into your n8n instance
  2. Configure Credentials โ†’ Set up all required FTP and SMTP connections
  3. Customize Schedule โ†’ Adjust cron expression for your timing needs
  4. Set File Filters โ†’ Configure regex patterns for your file types
  5. Configure Paths โ†’ Set source and destination directory structures
  6. Test Thoroughly โ†’ Run with test files before production deployment
  7. Enable Monitoring โ†’ Activate email notifications and logging

Customization Options

๐Ÿ“… Scheduling Examples

0 2 * * *     # Daily at 2 AM
0 */6 * * *   # Every 6 hours  
0 8 * * 1-5   # Weekdays at 8 AM
0 0 1 * *     # Monthly on 1st
*/15 * * * *  # Every 15 minutes

๐Ÿ” File Filter Patterns

# Documents
\\.(pdf|doc|docx|xls|xlsx)$

# Images  
\\.(jpg|jpeg|png|gif|svg)$

# Data Files
\\.(csv|json|xml|sql)$

# Archives
\\.(zip|rar|7z|tar|gz)$

# Size-based (add as condition)
{{ $json.size > 1048576 }}  # Files > 1MB

# Date-based (recent files only)
{{ $json.date > $now.minus({days: 7}) }}

๐Ÿ“ Directory Organization

// Date-based structure
/files/{{ $now.format('YYYY/MM/DD') }}/

// Type-based structure  
/files/{{ $json.name.split('.').pop() }}/

// User-based structure
/users/{{ $json.owner || 'system' }}/

// Hybrid approach
/{{ $now.format('YYYY-MM') }}/{{ $json.type }}/

Template Features

๐Ÿ›ก๏ธ Safety & Security

๐Ÿ“ง Notification System

Success Notifications:

Error Notifications:

๐Ÿ“Š Monitoring & Analytics

Production Considerations

๐Ÿš€ Performance Optimization

๐Ÿ”ง Maintenance

Testing Protocol

๐Ÿงช Pre-Production Testing

  1. Phase 1: Test with 1-2 small files (< 1MB)
  2. Phase 2: Test error scenarios (invalid credentials, network issues)
  3. Phase 3: Test with representative file sizes and volumes
  4. Phase 4: Validate email notifications and logging
  5. Phase 5: Full production deployment with monitoring

โš ๏ธ Important Testing Notes

Support & Documentation

This template includes:

Technical Specifications

Who is this for?

๐ŸŽฏ Primary Users

๐Ÿ’ผ Industries & Use Cases

๐Ÿ”— Nodes Used

Send Email, FTP, Schedule Trigger, Filter

๐Ÿ“ฅ Import

Download workflow.json and import into n8n: Workflow menu โ†’ Import from File

๐Ÿ“– Importing guide ยท ๐Ÿ”‘ Credential setup