Skip to main content

Automate workflow & credentials backup to S3 with retention management

Workflow preview

Workflow preview
100%
Automate workflow & credentials backup to S3 with retention management preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This n8n template automates daily backups of workflows and credentials to S3 compatible storage with automatic retention management. Designed for self hosted n8n instances requiring disaster recove...

Best for

  • DevOps automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.n8n, n8n-nodes-base.set, n8n-nodes-base.filter, n8n-nodes-base.s3, n8n-nodes-base.executecommand, n8n-nodes-base.readwritefile, n8n-nodes-base.scheduletrigger, n8n-nodes-base.stickynote

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Tobias Mende.

Original n8n.io source

1.1 Workflow description

Title
Automate workflow & credentials backup to S3 with retention management
Workflow name
Automate workflow & credentials backup to S3 with retention management

This n8n template automates daily backups of workflows and credentials to S3-compatible storage with automatic retention management. Designed for self-hosted n8n instances requiring disaster recovery protection.

The workflow has three tasks: backs up all workflows via n8n API, exports and stores credentials securely, and automatically deletes outdated backups based on configurable retention policies. Perfect for administrators needing automated backup solutions with storage cost management.

Target Audience

  • n8n Administrators: Managing production n8n instances requiring reliable backup solutions
  • DevOps Teams: Implementing disaster recovery strategies for automation infrastructure
  • IT Managers: Ensuring business continuity and compliance for critical automation workflows
  • System Administrators: Maintaining secure, automated backup processes for workflow management platforms

How it works

The workflow operates through three synchronized branches that execute automatically on a daily schedule:

Workflow Backup Process: The schedule trigger initiates daily backups, retrieving all workflows via the n8n API and storing them as timestamped JSON files in your S3 bucket.

Retention Management: Simultaneously, the system lists existing backup files, extracts dates from filenames, applies retention policies to identify outdated backups, and automatically deletes files beyond the configured retention period.

Credential Backup: In parallel, the workflow exports all n8n credentials to a temporary file, uploads the encrypted credential data to S3 storage, and securely removes temporary files from the local system.

Prerequisites

Before implementing this template, ensure you have the following requirements in place:

Self-Hosted n8n Instance: This template requires a self-hosted n8n installation with file system access for credential export functionality. Cloud-hosted n8n instances cannot export credentials due to security restrictions.

S3-Compatible Storage: Set up an S3 bucket (AWS S3, MinIO, DigitalOcean Spaces, or any S3-compatible service) with read/write permissions configured for your backup storage needs.

Access Credentials: Obtain S3 access credentials (Access Key ID and Secret Access Key) with appropriate bucket permissions for file operations (create, delete, list).

System Permissions: Ensure your n8n instance has command-line access and file system permissions for credential export and temporary file management operations.

Setup Instructions

Step 1: S3 Bucket Configuration

Create and configure your S3-compatible storage bucket:

  1. Create a new S3 bucket in your preferred region
  2. Configure bucket policies for read/write access
  3. Generate access credentials (Access Key ID and Secret Access Key)
  4. Note the bucket name, region, and endpoint URL for configuration

Step 2: Import and Configure Template

  1. Import this workflow template into your n8n instance
  2. Navigate to the Config node (Manual Trigger) to customize settings
  3. Configure the following parameters:
    • Bucket name and region
    • Retention period (default: 7 days)
    • Backup file naming conventions
    • Folder structure preferences

Step 3: Set Up S3 Credentials

Configure S3 credentials in all storage-related nodes.

Step 4: Set Up N8N Credentials

Create an API key for n8n via the n8n settings of your n8n instance.

Set this API key in the n8n node configuration. These credentials are neccesary to retrieve all workflows.

Step 5: Configure Backup Schedule

Customize the Daily Backup schedule trigger:

  • Daily at 2:00 AM: 0 2 * * *
  • Daily at midnight: 0 0 * * *
  • Twice daily: 0 0,12 * * *
  • Custom schedule: Modify cron expression as needed

Step 6: Test and Validate

  1. Execute the Config node manually to verify settings
  2. Run the complete workflow to test all three backup branches
  3. Verify files appear in your S3 bucket with correct naming
  4. Confirm retention policies work by checking cleanup operations
  5. Test credential backup and temporary file removal

Retention Settings

The retention management system automatically maintains your backup storage:

Configurable Retention Period: Set how many days of backups to retain (default: 31 days). The system automatically calculates cutoff dates and removes older files.

Date-Based Cleanup: The Extract Date node processes backup filenames to determine file age, while the Keep Outdated Backups filter identifies files beyond the retention period.

Automatic Deletion: Outdated files are automatically removed from S3 storage, preventing unlimited storage growth and managing costs effectively.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Get many workflows

Type / Role
n8n-nodes-base.n8n - n8n
Config choices
Version 1

Block 2 - Config

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 3 - Extract Date

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 4 - Keep Outdated Backups

Type / Role
n8n-nodes-base.filter - filter
Config choices
Version 2.2

Block 5 - Delete Outdated Backups

Type / Role
n8n-nodes-base.s3 - s3
Config choices
Version 1

Block 6 - Export Credentials

Type / Role
n8n-nodes-base.executeCommand - executeCommand
Config choices
Version 1

Block 7 - Load Credentials

Type / Role
n8n-nodes-base.readWriteFile - readWriteFile
Config choices
Version 1

Block 8 - Delete Temporary File

Type / Role
n8n-nodes-base.executeCommand - executeCommand
Config choices
Version 1

Block 9 - Store Credentials Backup

Type / Role
n8n-nodes-base.s3 - s3
Config choices
Version 1

Block 10 - Store Workflow Backup

Type / Role
n8n-nodes-base.s3 - s3
Config choices
Version 1

Block 11 - Daily Backup

Type / Role
n8n-nodes-base.scheduleTrigger - scheduleTrigger
Config choices
Version 1.2

Block 12 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 14 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - Sticky Note3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 16 - Sticky Note4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 17 - Get Existing Backups

Type / Role
n8n-nodes-base.s3 - s3
Config choices
Version 1

Block 18 - Sticky Note5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 19 - Sticky Note6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

3. Summary Table

Workflow Automate workflow & credentials backup to S3 with retention management
Complexity advanced
Nodes 19
Categories DevOps
Author Tobias Mende
Published 25 Jul 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/6436/6436.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Automate workflow & credentials backup to S3 with retention management do?

This n8n template automates daily backups of workflows and credentials to S3 compatible storage with automatic retention management. Designed for self hosted n8n instances requiring disaster recove...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your DevOps use case.