Skip to main content

Restore and recover n8n credentials from Google Drive backups with duplication protection

Workflow preview

Workflow preview
100%
Restore and recover n8n credentials from Google Drive backups with duplication protection 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 workflow template uses community nodes and is only compatible with the self hosted version of n8n. Restore n8n Credentials from Google Drive Backup This template enables you to restore you...

Best for

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

Tools used

n8n-nodes-base.extractfromfile, n8n-nodes-base.if, n8n-nodes-base.n8n, n8n-nodes-base.googledrive, n8n-nodes-base.executecommand, n8n-nodes-base.code, n8n-nodes-base.aggregate, n8n-nodes-base.splitout

Source and attribution

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

Original n8n.io source

1.1 Workflow description

Title
Restore and recover n8n credentials from Google Drive backups with duplication protection
Workflow name
Restore and recover n8n credentials from Google Drive backups with duplication protection

This n8n workflow template uses community nodes and is only compatible with the self-hosted version of n8n.

Restore n8n Credentials from Google Drive Backup

This template enables you to restore your n8n credentials from a backup file in Google Drive. It's an essential companion to a credential backup workflow, ensuring you can recover your setup in case of data loss, instance migration, or disaster recovery. The workflow intelligently checks for existing credentials to prevent accidental overwrites of credentials with the same name that are already present. This workflow is manually triggered.

We recommend you use this restore workflow in conjunction with a backup solution like our "Auto Backup Credentials to Google Drive" template.

For more powerful n8n templates, visit our website or contact us at AI Automation Pro. We help your business build custom AI workflow automation and apps.

Who is this for?

This workflow is for n8n administrators and users who have backed up their n8n credentials to Google Drive (e.g., using a companion backup template) and need to restore them to the same or a different n8n instance. It's crucial for those managing self-hosted instances.

What problem is this workflow solving? / use case

If an n8n instance becomes corrupted, needs to be migrated, or if credentials are accidentally deleted, a manual re-creation of all credentials can be extremely time-consuming and error-prone. This workflow automates the restoration process from a known backup, saving significant time and ensuring accuracy. It's particularly useful for:

  • Disaster recovery.
  • Migrating n8n instances.
  • Quickly setting up a new n8n instance with existing credentials.

What this workflow does

The workflow is manually triggered and performs the following operations:

  1. Fetch Current Credentials:
    • An "On Click Trigger" starts the process.
    • It executes the command npx n8n export:credentials --all --decrypted via the "Execute Command Get All Credentials" node to get a list of all credentials currently in your n8n instance.
    • This list is then processed by "JSON Formatting Data" and "Aggregate Credentials" nodes to extract just the names of existing credentials for comparison.
  2. Download Backup File from Google Drive:
    • The "Google Drive Get Credentials File" node searches your Google Drive for the n8n_backup_credentials.json file.
    • The "Google Drive Download File" node then downloads the found file.
  3. Process Backup Data:
    • The "Convert Files To JSON" (an Extract From File node) converts the downloaded file content, expected to be JSON, into a usable JSON object.
    • "Split Out" nodes then process this data to handle individual credential entries from the backup file.
  4. Loop and Restore Credentials:
    • The "Loop Over Items" (a SplitInBatches node) iterates through each credential from the backup file.
    • Duplicate Check: For each credential, an "IF" node ("Check For Skipped Credentials") checks two conditions using an OR combinator:
      • If the credential name from the backup ($('Loop Over Items').item.json.name) is empty.
      • If a credential with the same name already exists in the current n8n instance (by checking against the list from the "Aggregate Credentials" node).
    • Conditional Restore: If the credential name is NOT empty AND it does NOT already exist (i.e., the conditions in the IF node are false), the workflow proceeds to the "Restore N8n Credentials" node (an n8n API node). This node uses the name, type, and data for each new credential from the backup file to create it in the n8n instance. Credentials with empty names or those already present are skipped as they take the true path of the IF node, which loops back.
    • A "Wait" node introduces a 1-second delay after each restoration attempt, to prevent API rate limiting before looping to the next item.

Step-by-step setup

  1. n8n Instance Environment (for current credentials check):
    • The n8n instance must have access to npx and n8n-cli for the "Execute Command Get All Credentials" node to function.
  2. Google Drive Credentials:
    • Configure the "Google Drive Get Credentials File" and "Google Drive Download File" nodes with your Google OAuth2 credentials.
  3. n8n API Credentials:
    • Configure the "Restore N8n Credentials" node with your n8n API credentials. This API key needs permissions to manage credentials.
  4. Backup File Name:
    • The workflow is configured to search for a file named n8n_backup_credentials.json in the "Google Drive Get Credentials File" node. If your backup file has a different name or you want to specify a path, update the "Query String" parameter in this node.

How to customize this workflow to your needs

  • Backup File Location/Query: Modify the "Google Drive Get Credentials File" node parameters if your backup file is in a specific folder, has a different naming convention, or if you want more specific query logic.
  • Overwrite Logic: The current workflow skips existing credentials by name. If you need to update/overwrite existing credentials, you would need to modify the logic in the "Check For Skipped Credentials" (IF) node and potentially use an "update" operation in the "n8n" API node if available for credentials (note: updates often require the credential ID, which might not be in the backup file).
  • Notifications: Add notification steps (e.g., Email, Slack) to report on the success or failure of the restoration process, and to list which credentials were restored or skipped.
  • Selective Restore: To restore only specific credentials, you could add a filter step after "Split Out1" or modify the IF condition in "Check For Skipped Credentials" to check for particular credential names or types from the backup file.
  • Error Handling: Implement more robust error handling for API errors (e.g., from the n8n API node or Google Drive nodes), file not found issues, or problems during command execution.

Important Note on Credential Security

  • Decrypted Backup File: This workflow assumes the n8n_backup_credentials.json file contains decrypted credential data, typically created by a companion backup workflow.
  • Execution Environment: The "Execute Command Get All Credentials" node requires npx n8n-cli access on the server running n8n.

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 - Convert Files To JSON

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

Block 2 - Check For Skipped Credentials

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

Block 3 - Restore N8n Credentials

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

Block 4 - Google Drive Download File

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

Block 5 - Google Drive Get Credentials File

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

Block 6 - Execute Command Get All Cridentials

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

Block 7 - JSON Formatting Data

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

Block 8 - Aggregate Cridentials

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

Block 9 - Split Out

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

Block 10 - Loop Over Items

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

Block 11 - Split Out1

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

Block 12 - Sticky Note2

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

Block 13 - Wait

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

Block 14 - On Click Trigger

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

3. Summary Table

Workflow Restore and recover n8n credentials from Google Drive backups with duplication protection
Complexity intermediate
Nodes 14
Categories DevOps
Author Daniel Ng
Published 30 May 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/4518/4518.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 Restore and recover n8n credentials from Google Drive backups with duplication protection do?

This n8n workflow template uses community nodes and is only compatible with the self hosted version of n8n. Restore n8n Credentials from Google Drive Backup This template enables you to restore you...

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.