The dependable pattern is to export n8n workflows on a schedule, store one readable JSON file per workflow, compare that tree with the previous repository version, commit only additions, changes, and deletions, then push to a private GitHub repository. For self-hosted n8n, the CLI is usually the clearest implementation. An n8n API workflow can perform the same job inside n8n, while built-in source-control environments provide branch-based promotion on eligible plans.
Antihost offers VPS plans with one-click n8n, NVMe storage and a 14-day free trial.
A workflow export is not a complete disaster-recovery backup. Recovery also requires the n8n database, deployment configuration, environment variables, encryption key, and any external storage settings. Design the Git repository as one part of a tested recovery procedure, not as a substitute for database and secret backups.
As an Amazon Associate I earn from qualifying purchases.
What an automatic n8n backup should accomplish
A useful backup answers four operational questions: what changed, when it changed, how to restore it, and whether sensitive material is protected. The repository should make workflow history easy to review without placing decrypted credentials or encryption keys in ordinary Git files.
- One file per workflow: Separate JSON files produce readable diffs and let you restore an individual workflow without importing an unrelated collection.
- Deterministic change detection: The export tree must represent the current n8n state. Added and modified files should be committed, while files for deleted workflows must disappear from the tree so Git records the deletion.
- Private, least-privilege storage: Use a private repository and a GitHub token limited to the target repository. Treat every credential export and encryption key as a secret.
- Recoverable deployment: Keep operational notes covering the n8n version, branch, schedule, retention, required environment-variable names, and the person responsible for a restore exercise.
Decide whether your policy protects the current saved (draft) state, the published state, or both. n8n’s source-control tutorial explicitly says it pushes the current saved version, not the published version. A team that needs published-state fidelity must define how that state is captured and verify the result during a restore test.
#1 Best Overall
- Easily store and access 2TB to content on the go with the Seagate Portable Drive, a USB external hard drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Choose the automation method
| Method | Backup completeness | Saved versus published fidelity | Secret handling | Restore capability | Availability | Change and deletion detection | Operational complexity |
|---|---|---|---|---|---|---|---|
| n8n CLI plus ordinary Git | Workflow and optional credential exports; database, configuration, key, environment, and external storage remain separate. | Captures the state exposed by the self-hosted instance; it does not provide a separate published-state guarantee. | Credentials can be exported separately and must be protected; never commit decrypted output or the encryption key. | Strong for self-hosted operators who also back up the database and deployment. | Requires host, container, or job access to the n8n CLI. | Git handles diffs; replace the export directory so removed workflows become deletions. | Low to moderate; a shell job and scheduler are transparent. |
| n8n API plus GitHub Data API | Can capture workflows and inventory data, but still does not replace database, configuration, key, or external-storage backups. | Depends on which API data the workflow reads; define and test the chosen state. | Requires n8n API credentials and a narrowly scoped GitHub token; keep both in n8n’s protected credential store. | Good for workflow-level restores when exports are normalized and complete. | Runs inside n8n where API access and outbound GitHub access are available. | Can normalize volatile fields and explicitly remove orphaned files, including renames and deletions. | Moderate to high; loop prevention, API pagination, rate limits, and security are your responsibility. |
| Built-in source-control environments | Provides branch-oriented workflow synchronization, not a complete infrastructure backup. | n8n documents that the pushed version is the current saved version, not the published version. | Uses the source-control connection, but credentials and encryption keys still need a separate policy. | Useful for moving workflows between connected environments; test a full outage restore separately. | Available on Business and Enterprise plans. | Branch push and pull provide the change model; follow the documented process for your environments. | Lower day-to-day Git plumbing, but higher plan and environment requirements. |
| n8n CLI package export | Useful for portable folders and dependency-aware moves; it is not a replacement for a complete backup. | Depends on the package contents and the state you export. | Apply the same rule: secrets and encryption keys stay outside ordinary repository files. | Helpful for moving projects, but validate compatibility before relying on it for disaster recovery. | The .n8np package format is documented as beta and may change. |
Git can version the package, but file-level review is less transparent than separate workflow JSON files. | Moderate; convenient for portability, less ideal for human-readable history. |
For most self-hosted installations, start with CLI plus ordinary Git. Choose the API route when n8n must own the schedule and repository writes. Choose built-in environments when your plan and promotion workflow justify the integration. Treat package export as a portability tool rather than your only recovery artifact.
Prepare the private GitHub repository
Create a repository with an initial commit
Create a private repository and make an initial commit before the first automated push. The initial tree can contain a README, an inventory, operational notes, and empty directories or placeholder-free directory creation handled by the backup job. Keep the branch name explicit; many teams use main, but your policy may require a dedicated backup branch.
A practical layout is:
backups/workflows/ # one readable JSON file per workflow
backups/inventory.md # owner, schedule, n8n version, and scope
ops/restore.md # ordered recovery procedure
ops/retention.md # retention and deletion policy
Do not add decrypted credential exports, N8N_ENCRYPTION_KEY, database dumps containing secrets, or deployment tokens to these ordinary paths. If credential files must be retained, place them in a separately protected backup system with access controls and encryption appropriate to their sensitivity.
Limit the GitHub token
The automation only needs to write to its target private repository. Create a token with the smallest repository scope that supports the required branch operations, store it in the host secret store or n8n’s protected credential store, and rotate it under the same procedure as other production secrets. A failed push should alert an operator; it should not cause the job to print the token into logs.
Method 1: scheduled n8n CLI exports with ordinary Git
Export workflows as separate readable files
On a self-hosted installation, run:
n8n export:workflow --backup --output=backups/workflows/
The --backup flag sets the equivalent of --all --pretty --separate. That means all workflows are exported, JSON is formatted for review, and each workflow receives its own file. Separate files make a pull request or commit understandable: a changed workflow produces a focused diff instead of rewriting one large archive.
Export credentials separately only when your recovery policy requires it:
Free tools Windows power users keep installed
One-click scans. No signup required.
n8n export:credentials --backup --output=backups/credentials/
Keep that output outside the ordinary Git tree unless you have an explicitly protected, encrypted secret-backup design. Credential exports are encrypted unless you deliberately export them decrypted. Decrypted files are highly sensitive and should never be treated like normal source code.
Replace the export tree so deletions are recorded
Writing new files over an old directory can leave a stale JSON file after a workflow is deleted. Build the export in a temporary directory, replace the tracked workflow directory, and then let Git calculate the difference. The following example intentionally exports credentials to a separate protected directory and commits workflow files, inventory, and operational notes only:
Rank #2
- Easily store and access 5TB of content on the go with the Seagate portable drive, a USB external hard Drive
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
#!/usr/bin/env bash
set -euo pipefail
REPO_DIR=${REPO_DIR:-/srv/n8n-backup-repo}
BRANCH=${BRANCH:-main}
SECURE_DIR=${SECURE_DIR:-/srv/n8n-secure-exports}
TMP_DIR=$(mktemp -d)
trap 'rm -rf "$TMP_DIR"' EXIT
mkdir -p "$REPO_DIR/backups" "$SECURE_DIR"
cd "$REPO_DIR"
n8n export:workflow --backup --output="$TMP_DIR/workflows/"
rm -rf "$REPO_DIR/backups/workflows"
mv "$TMP_DIR/workflows" "$REPO_DIR/backups/workflows"
n8n export:credentials --backup --output="$SECURE_DIR/credentials/"
git add -A backups/workflows backups/inventory.md ops
if ! git diff --cached --quiet; then
git commit -m "n8n backup $(date -u +%Y-%m-%dT%H:%M:%SZ)"
git push origin "$BRANCH"
fi
The example uses a temporary directory so a deleted workflow becomes a Git deletion. Adapt directory permissions, service-user ownership, and credential-export retention to your deployment. If the n8n command is available only inside a container, run the same sequence as a container job with the repository mounted read-write and the secure credential destination mounted separately.
Schedule and observe the job
Use the host scheduler, a container job, or a dedicated automation workflow. A cron entry for a daily 02:15 UTC run could be:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →15 2 * * * /usr/local/bin/backup-n8n.sh >> /var/log/n8n-backup.log 2>&1
Choose a time zone and frequency that match your change rate and recovery point objective. The scheduler should report non-zero exits, failed exports, authentication errors, and rejected pushes. A job that runs but silently skips commits is not proof of a valid backup; inspect the repository history and periodically perform a restore test.
Method 2: run the backup inside n8n with its API and GitHub Data API
An n8n-native workflow can remove the requirement for a separate host scheduler. The basic flow is a schedule trigger, an authenticated read of the workflows, normalization, comparison with the repository tree, and GitHub commits through the GitHub Data API.
- Trigger on a fixed schedule. Record the run time and a correlation identifier so an operator can connect an alert to a specific backup attempt.
- Read the intended workflow state. Use an n8n API credential with only the permissions required to list and retrieve workflows. Decide whether the response represents drafts, saved workflows, or another state, and document that decision.
- Normalize only known volatile fields. If the API includes values that change on every read without representing a workflow edit, remove or canonicalize those fields. Keep an allowlist of transformations and review it after n8n upgrades; over-normalization can hide a real change.
- Generate one deterministic JSON document per workflow. Use a stable filename rule and a format that remains readable in Git. If names can change, use a stable identifier in the filename and keep the human-readable name inside the JSON or inventory.
- Read the target branch tree. Compare the generated set with the files currently present in the repository. Create blobs for new or changed files, delete files that no longer correspond to a workflow, and create one commit containing the complete tree change.
- Push the commit to the intended branch. Refuse to overwrite an unexpected branch tip unless your conflict policy explicitly allows it. Record the commit identifier in the execution log.
The critical difference from a simple append-only export is deletion handling. Without an explicit comparison against the existing tree, a renamed or deleted workflow can leave an orphaned JSON file that looks like a valid backup but restores obsolete logic.
Secure the in-n8n implementation
- Store the n8n API credential and GitHub token as protected n8n credentials, not as literal node parameters copied into documentation.
- Guard against self-triggering loops if the backup workflow changes its own data or if repository events can invoke n8n.
- Set timeouts, retry limits, and an alert path for API rate limits or partial reads. A partial export must fail closed rather than commit an incomplete tree.
- Log counts and hashes rather than full credential payloads. Keep enough metadata to prove that all expected workflows were processed.
- Run the workflow with a dedicated service identity and restrict outbound and repository permissions to what the backup needs.
This option is powerful, but its code becomes part of your recovery system. Keep the backup workflow itself documented and export it through an independent path so that losing the main n8n instance does not also remove the only automation that knows how to back it up.
Method 3: n8n source-control environments
n8n’s built-in source-control environments connect n8n instances to Git branches and provide documented push and pull operations for moving work between environments. This can reduce custom scripting when a team already has development, staging, and production instances.
Source-control environments are available on Business and Enterprise plans. Confirm that the plan, instance topology, and branch policy match your deployment before making it the only change path.
Rank #3
- Easily store and access 1TB to content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop. Reformatting may be required for Mac
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Account for saved-versus-published behavior
The documented behavior is precise: n8n pushes the current saved version, not the published version, of a workflow. That distinction matters when an editor has changed a draft but production still runs an older published revision. Decide whether your backup objective is editor history, production behavior, or both. If production behavior is the objective, include a separate, tested process that records the published state and its deployment timing.
Use branch rules deliberately
- Assign one branch to each environment or promotion stage and document who may push or pull.
- Do not treat a successful branch synchronization as proof that the database, encryption key, environment variables, and external storage are backed up.
- Schedule independent database and configuration backups even when source control is enabled.
- Test a new-instance recovery, not only a branch pull into a functioning n8n deployment.
Method 4: n8n CLI package export
The n8n CLI package format, using .n8np, is designed for portable folders and dependency-aware moves. It can be useful when transferring a project between installations or preserving related items together. n8n documents the format as beta, so its structure and behavior may change.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchBecause a package is less transparent than one JSON file per workflow, keep ordinary workflow exports for day-to-day review even if you also retain packages. Test package import after n8n upgrades and keep the n8n version beside each package. Never assume a package alone contains your database, deployment environment, encryption key, or external storage.
Design Git history that remains useful
Make commits explain the change
Use a consistent message containing the UTC run time and, when available, the workflow count or backup job identifier. A commit should be created only when the staged tree differs from the previous commit. Empty commits add noise and make it harder to identify the last real change.
Keep generated data deterministic
Stable ordering, consistent pretty-printing, and a documented filename rule make diffs meaningful. In an API workflow, normalize only fields proven to be volatile. In a CLI workflow, avoid post-processing that changes JSON formatting between runs. Review a sample diff after n8n upgrades because exporter behavior can change.
Handle renames and deletions
If filenames are based on names, a rename appears as a delete plus an add; that is acceptable if the inventory records the relationship. If you need continuity, base filenames on a stable workflow identifier and keep the display name in the document. Regardless of naming, remove files that no longer exist in n8n. An orphaned file is a restoration hazard.
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Define retention and branch protection
Git history supplies versioning, but it does not automatically satisfy your retention or legal requirements. Document how long commits remain, who may delete history, and how to recover after an accidental push. Protect the backup branch from force-pushes where practical, and keep an independent copy of the repository or critical commits if your threat model includes repository loss.
Protect credentials and the encryption key
n8n states that “The encryption key is required to restore credentials.” Preserve the same N8N_ENCRYPTION_KEY value, or the equivalent n8n configuration, when rebuilding an instance. A workflow JSON export can be perfectly intact while encrypted credentials remain unusable because the replacement instance has a different key.
Rank #4
- Easily store and access 4TB of content on the go with the Seagate Portable Drive, a USB external hard drive.Specific uses: Personal
- Designed to work with Windows or Mac computers, this external hard drive makes backup a snap just drag and drop
- To get set up, connect the portable hard drive to a computer for automatic recognition no software required
- This USB drive provides plug and play simplicity with the included 18 inch USB 3.0 cable
- The available storage capacity may vary.
Credential exports are encrypted unless you explicitly export them decrypted. Encrypted exports still require the original encryption key during restoration. Decrypted exports should be treated as production secrets: store them in a separately encrypted location, restrict access, set a retention period, and remove them when the policy allows.
Keep the names of required environment variables in ops/restore.md, but keep their values in a secret manager or protected deployment system. Operational notes should tell the restorer where to retrieve a value, who owns it, and which n8n version or deployment component consumes it.
Restore n8n after a failure
Restoration is an ordered operation. Importing workflow JSON into a blank instance before restoring the database and encryption configuration can produce misleading success: the workflows may appear, while credentials, execution history, or deployment behavior remain broken.
- Provision a compatible n8n deployment. Record and match the n8n version documented by the backup. Recreate the runtime, container or host configuration, network access, and filesystem permissions.
- Restore the database. Use the database backup that belongs to the recovery point. A workflow repository does not contain the complete n8n database.
- Restore configuration and environment variables. Reapply deployment settings, queue or worker configuration where used, required environment-variable names and values, and external storage settings.
- Restore the n8n configuration directory or the same encryption key. The replacement instance must have the original
N8N_ENCRYPTION_KEYso encrypted credentials can be decrypted. n8n’s documentation states that this key is required. - Restore workflow files. Import the JSON files from the selected Git commit using the n8n CLI or the supported import path for your deployment. Record which commit was used.
- Restore credentials securely. Import the protected credential export while the original encryption key is active. If the export was intentionally decrypted, handle it as a secret and remove temporary plaintext copies immediately after use.
- Verify external dependencies. Check OAuth connections, databases, queues, file stores, webhook endpoints, and other services that are not contained in ordinary workflow JSON. Recreate their credentials and network permissions through your normal secret and infrastructure procedures.
- Test before enabling production traffic. Run representative workflows with production triggers disabled or isolated. Verify credential access, node behavior, schedules, webhooks, and any published-versus-saved policy before switching traffic.
Keep the restore owner and an escalation contact in the repository’s operational notes. A documented owner prevents a backup from becoming an unattended collection of files during an outage.
Test the backup instead of trusting the commit
Run a restoration exercise on a schedule that matches the importance of the n8n service. The test should use a clean or isolated environment and a known Git commit, not the still-running production instance.
- Confirm the scheduled job created or skipped a commit for the expected reason.
- Check that the workflow file count matches the source instance and that deletions are visible in Git.
- Open representative JSON files and inspect a diff for accidental volatile-field churn.
- Verify that protected credential exports exist in their separate backup location and are readable only by authorized operators.
- Restore the database, deployment configuration, encryption key, workflows, and credentials in the documented order.
- Execute a workflow that uses each important credential class and verify its trigger, nodes, and external connections.
- Record the elapsed restoration time and any manual step that should be added to
ops/restore.md.
Use the results to set a realistic recovery point and recovery time objective. A daily workflow export cannot recover edits made after the last successful run, and a repository commit cannot compensate for a missing database or encryption key.
Recommended Free Tools
Troubleshoot common failures
| Symptom | Likely cause | Correction |
|---|---|---|
| The job runs but no deleted workflow appears as a Git deletion. | The exporter wrote over an old directory and left orphaned files. | Export to a temporary directory, replace the tracked workflow tree, then stage with git add -A. |
| Every run creates a large diff. | Formatting or volatile API fields change on every export. | Keep CLI formatting stable or normalize only verified volatile fields in the API workflow. Review the transformation after upgrades. |
| Git push is rejected. | The token lacks repository or branch permission, the remote is wrong, or branch protection requires a different flow. | Verify the remote, target branch, token scope, and protection policy without printing secrets in logs. |
| Workflows restore but credentials fail. | The original encryption key was not restored, or the credential export is missing or from another recovery point. | Restore the same N8N_ENCRYPTION_KEY, use the matching encrypted export, and repeat the credential import. |
| Credential files are visible in ordinary Git history. | A decrypted export or secret was committed. | Stop distribution, rotate affected secrets, restrict repository access, and follow your organization’s Git-history cleanup procedure before resuming backups. |
| The source-control branch does not match what users see running. | Source control pushed the saved version while production uses the published version. | Define the desired state explicitly and add a separate published-state verification or capture process. |
| A package import behaves differently after an upgrade. | The .n8np format is beta and may change. |
Validate the package with the corresponding n8n version and retain separate JSON exports for review and fallback. |
| An API backup contains only part of the workflow set. | Pagination, rate limits, or a partial request was treated as success. | Fail the run on incomplete reads, record counts, retry within limits, and commit only a complete normalized tree. |
A practical policy for most self-hosted teams
Use the CLI export as the primary workflow archive, commit readable JSON to a private GitHub repository, and keep encrypted credential exports plus the encryption key in a separate protected backup system. Replace the export directory on every run so additions, edits, renames, and deletions are visible. Schedule the job through the host, container platform, or a dedicated automation service, and alert on any non-zero result or failed push.
Document the n8n version, branch, schedule, retention, environment-variable names, credential location, and restore owner next to the repository. If your organization uses Business or Enterprise source-control environments, you can use their branch workflow for promotion while retaining independent database, configuration, key, and external-storage backups. Whichever method you choose, perform a clean restoration exercise; only that test proves that the Git history is usable when the original n8n instance is unavailable.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




