Opens in a new tab
🚀 Your daily business tech & AI briefing — Subscribe free →

n8n self‑hosted: daily Docker backups that actually work

Zain A
Share this article

Introduction

What a self-hosted n8n instance stores

If n8n goes sideways, Docker won’t save your workflows — you need a daily backup of the data volume. This setup uses a one‑liner cron job and a compressed archive so you can restore in minutes without babysitting containers.

The cost of losing it

Lose the server without a backup and you rebuild every workflow and reconnect every credential by hand. Daily backups prevent that.

n8n self‑hosted: daily Docker backups that actually work

Identify What n8n Actually Stores

Database, data volume and workflows

A self-hosted n8n backup covers three items:

  • The database: PostgreSQL holds your workflows, credentials, and execution data.
  • The data volume: the Docker volume mounted into the n8n container.
  • The encryption key: it decrypts every saved credential.

Workflows live in the database, so a database dump protects them.

Execution history versus essentials

Not all data matters equally. Execution logs grow fast and can be rebuilt or ignored.

Workflows, credentials, and the key cannot be replaced. Prioritize those, and treat execution history as optional.

Secure the n8n Encryption Key

Why credentials are useless without it

Every saved API key in the database is scrambled with the encryption key.

Restore a PostgreSQL dump onto a new server without the original key, and your credentials cannot be decrypted. You would re-enter each one by hand.

Storing it apart from the server

Keep a copy somewhere that does not share a fate with your server. A backup stored beside the key on the same disk protects nothing.

Good options include:

  • A password manager such as 1Password, Bitwarden, or KeePass
  • A secrets service such as HashiCorp Vault or AWS Secrets Manager

Store the key once, then confirm you can retrieve it before you rely on it.

Dump the Database with pg_dump

Running the dump inside the Docker container

Use pg_dump through docker exec, so you do not install PostgreSQL tools on the host. Write the output to a dated file on the host:

  • Run pg_dump inside the PostgreSQL container with your database user and name.
  • Redirect the output to a file named with the date.
  • Compress it with gzip to save space.

Put these commands in a backup script. That script becomes the base for automated backups later.

SQLite setups

If you never configured PostgreSQL, n8n uses SQLite by default. The database is a file inside the n8n data volume.

Copy that file while n8n is stopped, or back up the whole Docker volume. A copy taken mid-write can be corrupted.

n8n self‑hosted: daily Docker backups that actually work

FAQ

What should I back up for self-hosted n8n?

The database, the data volume, and the encryption key. Execution history is optional.

How do I schedule daily n8n backups?

Run your backup script with cron once a day, then copy the output off the server.

Is there a tool to automate n8n backups?

Yes. A community tool called n8n Backup Manager runs alongside n8n in Docker Compose and supports hourly, daily, or cron scheduling.

Conclusion

A reliable n8n backup rests on three pieces: a pg_dump of your database, a copy of the data volume, and an encryption key stored away from the server.

Schedule the script with cron, copy it off-site, and test a restore before you need one.

References

Share this article

Stay in the Loop

Weekly tech insights, AI news and tools — straight to your inbox.

Newsletter Form (#4)

Contents