Skip to main content

Back up and restore n8n Docker workflows and credentials with GitHub and SSH

Workflow preview

Workflow preview
100%
Back up and restore n8n Docker workflows and credentials with GitHub and SSH preview
Open on n8n.io

1. Workflow Overview

Quick Overview This workflow backs up all n8n workflows and encrypted credentials from a self hosted Docker instance to a GitHub repository on a schedule, and provides a Basic Auth–protected form t...

Best for

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

Tools used

n8n-nodes-base.splitinbatches, n8n-nodes-base.scheduletrigger, n8n-nodes-base.github, n8n-nodes-base.ssh, n8n-nodes-base.code, n8n-nodes-base.splitout, n8n-nodes-base.converttofile, n8n-nodes-base.merge

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Hồ Đình Huy.

Original n8n.io source

1.1 Workflow description

Title
Back up and restore n8n Docker workflows and credentials with GitHub and SSH
Workflow name
Back up and restore n8n Docker workflows and credentials with GitHub and SSH

Quick Overview

This workflow backs up all n8n workflows and encrypted credentials from a self-hosted Docker instance to a GitHub repository on a schedule, and provides a Basic Auth–protected form to restore workflows and credentials by importing uploaded JSON backup files over SSH.

How it works

  1. Runs twice daily on a cron schedule to start a backup run.
  2. Creates timestamped workflows and credentials folders (via placeholder files) in the target GitHub repository.
  3. Connects to the Linux host over SSH and runs the n8n CLI in the Docker container to export all workflows and all encrypted credentials.
  4. Commits workflows-all.json and individual <workflow name>.json workflow backups to GitHub.
  5. Commits credentials-all.json and individual <name>_<type>.json encrypted credential backups to GitHub.
  6. Builds and commits a combined workflows-credentials.json file containing both exports for easy restoration.
  7. Accepts uploaded JSON files via a Basic Auth form, detects whether they contain workflows or credentials (single, bulk, or combined), and imports them into the target n8n Docker container over SSH.

Setup

  1. Create a private GitHub repository and add GitHub API credentials in n8n with permission to write files to that repository.
  2. Add SSH credentials for your Linux host and ensure the SSH user can run docker exec/docker cp against the n8n container.
  3. Update the Backup Configuration and Restore Configuration nodes with your GitHub owner, repository name, and the n8n Docker container name.
  4. Configure Basic Auth credentials for the restore form and deploy it behind HTTPS before activating the restore path.
  5. Ensure the destination n8n instance uses the same N8N_ENCRYPTION_KEY as the source so encrypted credentials can be restored.

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 - Loop: Single WF

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 2 - Loop: Single Cred

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 3 - Trigger Backup

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

Block 4 - Init Workflow Folder

Type / Role
n8n-nodes-base.github - github
Config choices
Version 1.1

Block 5 - Init Creds Folder

Type / Role
n8n-nodes-base.github - github
Config choices
Version 1.1

Block 6 - Export Workflows

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

Block 7 - Export Credentials

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

Block 8 - Parse Workflow Export

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 9 - Parse Creds Export

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 10 - Split Workflows

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

Block 11 - Split Credentials

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

Block 12 - Convert All WFs to JSON

Type / Role
n8n-nodes-base.convertToFile - convertToFile
Config choices
Version 1.1

Block 13 - Convert Single WF to JSON

Type / Role
n8n-nodes-base.convertToFile - convertToFile
Config choices
Version 1.1

Block 14 - Prep All WFs Payload

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 15 - Push Single Cred

Type / Role
n8n-nodes-base.github - github
Config choices
Version 1.1

Block 16 - Push Single WF

Type / Role
n8n-nodes-base.github - github
Config choices
Version 1.1

Block 17 - Prep Single WF Payload

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 18 - Prep Single Cred Payload

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 19 - Push All WFs

Type / Role
n8n-nodes-base.github - github
Config choices
Version 1.1

Block 20 - Convert Single Cred to JSON

Type / Role
n8n-nodes-base.convertToFile - convertToFile
Config choices
Version 1.1

Block 21 - Prep All Creds Payload

Type / Role
n8n-nodes-base.code - code
Config choices
Version 2

Block 22 - All Creds to JSON

Type / Role
n8n-nodes-base.convertToFile - convertToFile
Config choices
Version 1.1

Block 23 - Push All Creds

Type / Role
n8n-nodes-base.github - github
Config choices
Version 1.1

Block 24 - Merge WFs & Creds

Type / Role
n8n-nodes-base.merge - merge
Config choices
Version 3.2

Showing the first 24 of 58 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Back up and restore n8n Docker workflows and credentials with GitHub and SSH
Complexity advanced
Nodes 58
Categories DevOps
Author Hồ Đình Huy
Published 09 Jun 2026

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/16191/16191.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 Back up and restore n8n Docker workflows and credentials with GitHub and SSH do?

Quick Overview This workflow backs up all n8n workflows and encrypted credentials from a self hosted Docker instance to a GitHub repository on a schedule, and provides a Basic Auth–protected form t...

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.