⚙️ Create restorable n8n Docker backups in Google Drive via SSH
⚡ 14 views · ⚙️ DevOps & CI/CD
Description
Quick overview
This workflow backs up n8n workflows and encrypted credentials from a self-hosted Docker instance via SSH, stores the exports as JSON files in structured Google Drive folders, and provides a Basic Auth–protected form to restore uploaded backups back into an n8n Docker container.
How it works
- Runs on a cron schedule to start a backup and set the target n8n Docker container name and timestamp.
- Creates a timestamped backup folder in Google Drive with subfolders for workflows and credentials.
- Connects over SSH and runs the n8n CLI inside the Docker container to export all workflows and all credentials as JSON.
- Uploads a full
workflows-all.jsonexport and also uploads each workflow as its own JSON file into the Google Drive workflows folder. - Uploads a full
credentials-all.jsonexport and also uploads each credential as its own JSON file into the Google Drive credentials folder. - Builds a combined
workflows-credentials.jsonpackage from both exports and uploads it to the root of the Google Drive backup folder. - Accepts one or more uploaded
.jsonfiles through a Basic Auth–protected n8n form, detects whether they contain workflows or credentials, then copies a generated import file to the target container over SSH and runsn8n import:workflowand/orn8n import:credentials.
Setup
- Add a Google Drive OAuth2 credential and set the parent Google Drive folder ID where backup folders should be created.
- Add an SSH credential with access to the Docker host and ensure the SSH user can run
docker execanddocker cpagainst the n8n container. - Replace the Docker container name for both backup and restore configuration so the SSH commands target the correct n8n instance.
- Configure Basic Auth for the restore form and copy the form URL for the admins who will upload backup files.
- Ensure the destination n8n instance uses the same
N8N_ENCRYPTION_KEYas the source if you plan to restore credentials.
🔗 Nodes Used
Google Drive, SSH, Schedule Trigger, n8n Form Trigger, Convert to File, Extract from File
📥 Import
Download workflow.json and import into n8n:
Workflow menu → Import from File