Automated FTP Backup Restoration for Credentials and Workflows - n8n Workflow

Restore n8n workflows and credentials seamlessly from a remote FTP backup using this robust n8n template. Ideal for migration and disaster recovery of self-hosted n8n instances.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

โ€ข Self-hosted n8n users requiring a reliable disaster recovery plan.
โ€ข System administrators managing n8n instances.
โ€ข Users needing to migrate all n8n templates and credentials from one server to another.
โ€ข Anyone looking for an advanced example of using the n8n Execute Command node for infrastructure operations.

Overview

Managing infrastructure requires robust backup and restoration capabilities. This specialized n8n workflow provides a complete solution for importing backed-up n8n data (both workflows and sensitive credentials) from a remote FTP server directly into a running n8n instance. This n8n template is essential for self-hosted users performing instance migration or disaster recovery. The automation intelligently identifies the latest date-stamped backup folder, downloads the necessary files to a temporary local directory, and utilizes core n8n shell commands (n8n import:workflow and n8n import:credentials) to automate the restoration process, saving critical administrative time. This comprehensive n8n node structure ensures a complete and verified recovery.

How it Works

The process is initiated by a manual n8n trigger, allowing the user to select whether to restore credentials, workflows, or both.


  1. Initialization and Listing: The workflow starts with the Start Restore manual n8n trigger. The Init node sets up configuration paths and the List Credentials Folders n8n node retrieves the directory structure from the FTP backup location.

  2. Find Latest Backup: The specialized Find Last Backup Code n8n node analyzes the FTP listing, identifies directories formatted as YYYY-MM-DD, and selects the most recent backup folder to ensure you are restoring the newest data.

  3. Local Setup: The Create Temp Folder n8n node uses a shell script to create temporary staging directories on the n8n server's local file system based on the selected backup date.

  4. Conditional Restoration (Credentials): If credentials restoration is enabled via the initial n8n trigger, the flow proceeds to download all credential JSON files from the FTP, writes them to the local temporary folder, and the Restore Credentials Execute Command n8n node runs the n8n import:credentials command to load them into the instance.

  5. Conditional Restoration (Workflows): If workflow restoration is enabled, the flow downloads all workflow JSON files. A filter node excludes non-workflow items. Crucially, the Exclude Current Workflow From Selection Execute Command n8n node runs a script to delete the running workflow's JSON file from the temporary directory to prevent accidental self-overwrite. Finally, the Restore Workflows Execute Command n8n node runs the n8n import:workflow command to import all files as new or updated n8n templates.

  6. Notification: Upon successful completion of either path, an email is sent via the SUCCESS email n8n node, detailing the restoration steps and results.

Installation Guide


  1. Import: Copy the provided n8n workflow JSON and import it into your self-hosted n8n instance.

  2. Credentials Setup:

FTP Credential: Create a new FTP credential linking to your remote backup server.
SMTP Credential (Optional): Set up an SMTP credential for success notifications (recommended).

  1. Code Node Configuration: Review the Init Code n8n node. Ensure the custom variables (PROJECTROOTPATH, FTPBACKUPFOLDER) match your server's file system and FTP configuration.

  2. Environment Variables: Ensure that required environment variables, especially N8NADMINEMAIL and the paths used in the Init n8n node, are correctly set on your n8n host system.

  3. Prerequisites: This n8n workflow relies on the hosting environment having access to the n8n command-line utility and standard shell tools (like mkdir, rm, ls) to execute the Execute Command n8n nodes.

Node Details

Start Restore (Manual n8n Trigger): The starting point. Its pinned parameters control which component (credentials or workflows) is targeted for restoration.
Init (Code n8n node): Establishes crucial configuration variables, including server paths, temporary folder names (like -restore-credentials), and timezone settings. These variables are passed dynamically throughout the entire n8n workflow.
Find Last Backup (Code n8n node): A core logic component. It processes the file listing from the FTP n8n node, identifies the most recent date-stamped backup folder, and dynamically constructs the full paths needed for downloading the files.
FTP n8n Node (List, Download): Used iteratively to list directories and then download the binary data of the credential and workflow JSON files from the remote server.
Execute Command n8n Node (Create Temp Folder): Uses shell commands to create the required temporary folders on the local file system where the downloaded files will be staged before import.
Execute Command n8n Node (Restore Credentials/Workflows): These are the critical nodes. They run native operating system commands, specifically n8n import:credentials and n8n import:workflow, pointing them to the staged local files to perform the actual data restoration into the n8n database.


  • Execute Command n8n Node (Exclude Current Workflow From Selection): A self-preservation mechanism. This specialized n8n node uses a shell script to locate and delete the running workflow's JSON file from the temporary restore directory, ensuring this specific n8n workflow is not overwritten during its execution.

Related n8n Workflows

Free

Nodes: 10 Nodes
Updated: December 26 2025
View all
Created by
Florent
Florent

IT Business Analyst for 8+ years, I am finding joy in developping again, with the help of n8n and AIs ๐Ÿค—

Featured*