Halloween

Up to 35% off servers Up to 35% off Starts in --d --:--:--

Menu
Free trial

Try it free for 24 hours

We keep two servers open, one in Germany and one in Miami. Join from Java or Bedrock, on whatever version you run, and see how they perform before paying for anything.

If after the trial you decide it's not for you, you pay nothing. If you keep it, billing starts the next day at the regular price.

n8n backups

What to back up from your n8n, how to copy the database, export workflows and credentials, and schedule it to run on its own every day.

50 views Updated 17 Oct 2026

Your VPS already has daily server backups; this guide covers your own application backups, which you can restore separately or take to another server. n8n does not make automatic backups by itself: you need to schedule them yourself. Here is what to keep and the commands to do it. They all run on your VPS over SSH as root.

What to keep

  • The database: workflows, credentials, users and execution history.
  • The encryption key N8N_ENCRYPTION_KEY, in /opt/n8n/.env. Without it, the credentials in the backup cannot be read.
  • The files you use in your workflows, in /opt/n8n/local-files (inside n8n, /files).

Database backup

mkdir -p /opt/n8n/backups
cd /opt/n8n && docker compose exec -T postgres sh -c 'pg_dump -U "$POSTGRES_USER" "$POSTGRES_DB"' | gzip > backups/n8n-$(date +%F).sql.gz

You get one file per day in /opt/n8n/backups/. The astrol-n8n-update command also makes a backup like this before every update.

Export workflows and credentials

Besides the database, you can export workflows and credentials to JSON files, which are handy to move them to another installation:

cd /opt/n8n
docker compose exec n8n n8n export:workflow --backup --output=/files/backup/workflows/
docker compose exec n8n n8n export:credentials --backup --output=/files/backup/credentials/

The files end up in /opt/n8n/local-files/backup/. Credentials are exported encrypted with your key.

Schedule a daily backup

Open the task scheduler with crontab -e and add these two lines. The first backs up the database every day at 04:00; the second deletes backups older than 7 days so the disk does not fill up:

0 4 * * * cd /opt/n8n && docker compose exec -T postgres sh -c 'pg_dump -U "$POSTGRES_USER" "$POSTGRES_DB"' | gzip > /opt/n8n/backups/n8n-$(date +\%F).sql.gz
30 4 * * * find /opt/n8n/backups -name 'n8n-*.sql.gz' -mtime +7 -delete

Keep backups off the VPS

A backup that only lives on the server itself does not protect you if you reinstall it or lose it. Download them to your computer, for example with:

scp root@YOUR_IP:/opt/n8n/backups/*.sql.gz .

Or with an SFTP client (FileZilla, WinSCP) logging in as root.

Restore workflows and credentials

To import what you exported into an n8n instance:

cd /opt/n8n
docker compose exec n8n n8n import:workflow --separate --input=/files/backup/workflows/
docker compose exec n8n n8n import:credentials --separate --input=/files/backup/credentials/

Important: encrypted credentials can only be imported into an n8n with the same N8N_ENCRYPTION_KEY. If you are moving them to a new installation, export with --decrypted instead of --backup: they are saved in plain text, so delete them as soon as you have imported them.

To restore the full database, open a ticket and we will guide you step by step: it is an operation best done calmly.

Order: n8n VPS in Frankfurt · in Miami

Was this article helpful?

Need more help?

Open a ticket and the support team goes through it with you.

Open a ticket