Automated Secure FTP/SFTP File Migration and Source Cleanup - n8n Workflow

Implement a robust n8n workflow for scheduled FTP/SFTP file migration, smart filtering, source cleanup, and success email notifications. Deploy this reliable n8n template for data automation.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • System Administrators and DevOps Teams: Needing reliable, scheduled data synchronization between remote servers.

  • Data Engineers: Requiring automated ETL precursors for processing file drops from external systems.

  • n8n Users: Looking for advanced n8n templates that showcase complex flow control (filtering, conditional logic) and file operations.

  • Businesses that rely on secure, automated file transfer (FTP/SFTP) as part of their daily operational requirements.

Overview

Manual FTP file migration is time-consuming, prone to human error, and lacks robust logging. This comprehensive n8n workflow eliminates those issues by providing a fully automated, scheduled solution. Using a specific n8n trigger, this workflow reliably connects to a source FTP, filters files based on criteria (currently TXT, CSV, JSON, XML), securely transfers them to a destination FTP, and then, crucially, deletes the source file only after successful upload verification. This ensures data integrity and prevents duplicate processing. This advanced n8n template includes logging via a Set n8n node and provides immediate success notifications via email, making it a professional-grade automation solution built entirely within n8n.

How it Works

This automation is initiated by a scheduled n8n trigger and executes a complex sequence of file operations:


  1. Scheduled Activation: The process begins daily at 2:00 AM using the Daily Schedule n8n trigger, ensuring off-peak execution.

  2. Source File Listing: The List Files - Source FTP n8n node connects to the origin server and retrieves a list of all files in the specified directory.

  3. Smart Filtering: The workflow proceeds to the Filter Files n8n node, which uses a regular expression to select only the desired file types (currently data and text files) for migration. This filtering step ensures only relevant files are processed by the n8n workflow.

  4. Download: For each filtered file, the Download File n8n node securely pulls the binary data from the source FTP into the n8n execution context.

  5. Upload: The Upload to Destination n8n node then takes the binary data and transfers it to the specified target FTP path.

  6. Validation: The Upload Success? n8n node acts as a conditional gate, checking the status of the preceding upload operation. If the upload was successful (True path), the workflow continues to cleanup.

  7. Source Cleanup: If validation succeeds, the Delete Source File n8n node removes the file from the original server, ensuring that it is not migrated again in the next cycle.

  8. Logging & Notification: The Log Success n8n node captures key metadata (timestamp, filename, size) for audit purposes, and the final Send Email Success Alert n8n node dispatches an email confirmation to the administrator, finalizing this reliable n8n workflow.

Installation Guide

To utilize this n8n workflow template, follow these steps:


  1. Import the n8n Template: Copy the provided JSON code and paste it into your n8n instance using the 'New' -> 'Import from JSON' function.

  2. Configure Credentials: You will need three sets of credentials:

Source FTP Credentials: Set up credentials for the 'List Files - Source FTP' n8n node. This account requires read/list/delete permissions.
Destination FTP Credentials: Set up separate credentials for the 'Upload to Destination' n8n node. This account requires write permission.
* SMTP Credentials: Configure SMTP credentials for the 'Send Email Success Alert' n8n node to ensure notifications function correctly.

  1. Set the n8n Trigger: Review the 'Daily Schedule (2 AM)' n8n trigger. Adjust the cron expression if you need the migration to run at a different time (e.g., during business hours or weekly).

  2. Adjust Paths and Filters: Update the source and destination paths in the respective FTP n8n node settings and modify the regular expression in the 'Filter Files' n8n node if you need to transfer different file types.

  3. Initial Testing: It is highly recommended to disable the 'Delete Source File' n8n node initially. Execute the n8n workflow manually to ensure files are transferred correctly before enabling the permanent cleanup step.

  4. Activate: Once testing is complete and verified, set the workflow status to 'Active'.

Node Details

Daily Schedule (2 AM) [n8n Trigger]: Initiates the entire n8n workflow execution daily using the cron expression 0 2 . This is the fundamental n8n trigger for all operations.
List Files - Source FTP [n8n Node]: Connects to the source server to list available files in the specified source directory (/source/directory/).
Filter Files [n8n Node]: A Core Logic n8n node that applies a regex filter (\.(txt|csv|json|xml)$) to ensure only data and text files are selected for the migration process.
Download File [n8n Node]: Performs the file download from the source, saving the binary data to the property file_data for transfer.
Upload to Destination [n8n Node]: Connects to the target FTP server and uploads the binary content, placing it in the destination path (/destination/directory/{{ $json.name }}).
Upload Success? [n8n Node]: A Filter n8n node used for conditional routing. It checks the output of the upload operation to ensure the transfer completed successfully before proceeding to cleanup.
Delete Source File [n8n Node]: The critical cleanup step. This FTP n8n node deletes the file from the source server only if the transfer was validated as successful, preventing re-processing.
Log Success [n8n Node]: A Set n8n node that creates structured data containing metadata about the successful transfer (timestamp, filename, size) for internal logging or later database insertion.
Send Email Success Alert [n8n Node]: Final action using the Email Send n8n node to notify administrators of the successful migration, including the subject line with the completion timestamp.

Related n8n Workflows

Free

Nodes: 6 Nodes
Updated: December 26 2025
View all
Created by

Featured*