Run n8n Locally for Free with Docker (Part 9 of 10): Backing Up and Restoring Your Instance
By Abhishek Patoliya · 2026-08-12
This is Part 9 of the series on running n8n locally with Docker for free. The volume from Part 4 protects your data from a container being removed and recreated — but not from a failing disk, an accidental docker volume rm, or a corrupted database file. This part covers an actual backup routine, and just as importantly, testing that the restore side of it really works.
← Back to the full series index
Backing Up the Whole Volume
The simplest reliable approach is archiving the entire volume to a file outside Docker's own storage:
docker run --rm \
-v n8n_data:/data \
-v $(pwd)/backups:/backup \
alpine \
tar czf /backup/n8n-backup-$(date +%Y%m%d).tar.gz -C /data .
This starts a temporary, throwaway Alpine Linux container that mounts your n8n_data volume alongside a local backups folder, and compresses everything from the volume into a dated .tar.gz file. Run this while the n8n container is stopped (docker compose stop) to avoid backing up a database file mid-write.
Restoring From a Backup
To restore into a fresh volume (useful for testing, or actually recovering after data loss):
docker volume create n8n_data_restored
docker run --rm \
-v n8n_data_restored:/data \
-v $(pwd)/backups:/backup \
alpine \
tar xzf /backup/n8n-backup-20260101.tar.gz -C /data
Then point your docker-compose.yml at n8n_data_restored instead of the original volume name and run docker compose up -d — n8n starts up with the restored data.
Testing the Restore (Don't Skip This)
A backup file you've never actually restored is a guess, not a real backup. Right after setting this up:
- Run the backup command above.
- Restore it into a new, separate volume as shown.
- Point a temporary n8n container at that restored volume and confirm your workflows, credentials, and settings all appear correctly.
Finding a problem with your backup process now, while nothing is actually lost, is a very different experience than finding it during a real recovery.
A Lighter-Weight Alternative: Exporting Workflows
For a quicker, partial backup — or to keep a specific workflow in version control separately from the full instance — n8n's CLI can export workflow definitions alone:
docker exec -it n8n n8n export:workflow --all --output=/home/node/.n8n/exported-workflows.json
This captures workflow logic but not credentials or execution history, so it's a complement to full volume backups, not a replacement for them.
Automating It
Once the backup command is working, a simple cron job on your host machine (not inside the container) running it daily or weekly — matched to how much rework you'd tolerate losing — turns this from a manual chore into something that happens without you thinking about it.
Next Up
With backups in place, the final part covers the moment most local setups actually break: Part 10: Upgrading Without Losing Your Workflows.
Written by Abhishek Patoliya, Senior n8n Developer & Automation Architect, Surat, India. Verified n8n Creator.