How to Automatically Back Up n8n: A Beginner's Guide (2025)
Learn how to create a simple, automated "set it and forget it" backup system to protect your hard work.
Get Started NowWhat You'll Need
A Working n8n Instance
This guide assumes your n8n is running on a VPS with Docker. If not, start with our Install Guide. Works perfectly on our recommended hosts, RackNerd, Hostinger, and Cloudways.
SSH Access
You need SSH access to your server to run the backup commands and set up the automated scripts.
Cloud Storage Account
For off-site backups, you'll need a free account with Google Drive, Dropbox, or a dedicated backup service like Backblaze B2.
Basic Command Line Knowledge
You should be comfortable with basic Linux commands like cd, ls, nano, and chmod. Don't worry - we'll provide exact commands to copy and paste.
What Are We Actually Backing Up?
The Simple Explanation
When you install n8n with Docker using the standard command, all of your critical data—workflows, credentials, execution logs—is stored in a single, safe place on your server: the ~/.n8n directory. Our entire backup strategy is focused on making a secure, compressed copy of this one folder.
- All your workflow configurations
- Stored credentials and API keys
- Execution history and logs
- Custom nodes and extensions
- User settings and preferences
Level 1: Automated Local Backups (The 5-Minute Setup)
This method will automatically create a compressed backup of your n8n data and save it to a separate folder on your VPS every night at 3 AM. This protects you against accidental deletions or workflow corruption.
Create a Backup Directory
First, let's create a folder to store our backups. Connect to your server via SSH and run:
mkdir /root/n8n-backups
Create the Backup Script
Next, we'll create a simple script that handles the backup process. Create the file with 'nano':
nano /root/backup-n8n.sh
Then, paste the following code into the editor. This script creates a compressed file with today's date.
#!/bin/bash
tar -czvf /root/n8n-backups/n8n-backup-$(date +%F).tar.gz -C /root/.n8n .
Press CTRL+X, then Y, then Enter to save and exit.
Make the Script Executable
We need to give the server permission to run this script:
chmod +x /root/backup-n8n.sh
Schedule the Script with Cron
Finally, we'll tell the server to run this script automatically every night. Open the cron scheduler:
crontab -e
Scroll to the bottom of the file and add this line, which means "run at 3:00 AM every day":
0 3 * * * /root/backup-n8n.sh
Save and exit. You're done! Your local backups are now fully automated.
Level 2: Automated Off-site Backups (Highly Recommended)
A local backup is good, but if your entire server fails, your backup is gone too. An off-site backup is your ultimate insurance policy. We'll use a fantastic free tool called 'rclone' to automatically sync our backups to the cloud.
Install and Configure Rclone
First, install rclone with one command:
curl https://rclone.org/install.sh | sudo bash
Next, configure it to connect to your cloud storage provider. Type rclone config and follow the prompts. The process is very straightforward. Here are direct links to guides for Google Drive, Dropbox, and Backblaze B2. Let's assume you named your remote "MyGoogleDrive".
Upgrade Your Backup Script
Now, let's add one line to our existing script. Open it again:
nano /root/backup-n8n.sh
Add the following line at the very end. This will copy the newly created backup file to a folder named 'n8n-backups' on your cloud drive.
rclone copy /root/n8n-backups/n8n-backup-$(date +%F).tar.gz MyGoogleDrive:n8n-backups/
That's it! Because this script is already scheduled with cron, you don't need to do anything else. Now, every night, your server will create a local backup and automatically upload a copy to your secure cloud storage.
How to Restore From a Backup
If the worst happens, restoring is simple. On a fresh server with Docker installed:
Download Your Backup
Download your latest backup file (e.g., n8n-backup-2025-08-24.tar.gz) from your cloud storage or local backup folder.
Stop and Remove Running Container
Stop and remove any running n8n container:
docker stop n8n && docker rm n8n
Extract the Backup
Extract the backup archive to the correct location:
tar -xzvf n8n-backup-2025-08-24.tar.gz -C /root/
Relaunch n8n
Relaunch n8n using the original Docker command. All your workflows and credentials will be back.
Backup Complete!
Your n8n instance is now fully protected with automated local and cloud backups. You can sleep soundly knowing your workflows are safe.
Frequently Asked Questions
Compressed backups are very small, usually only a few megabytes unless you have a lot of execution data. A free Google Drive account is more than enough.
Yes. Your credentials within n8n are already encrypted. For maximum security, you can use rclone's built-in encryption features when you configure it.
Absolutely! You can just copy the backup script, change the folder names (e.g., ~/.n8n to your other app's data folder), and set up another cron job.
For most users, daily backups are perfect. If you're making frequent changes to workflows, you might want to run backups every 6 hours. Just change the cron schedule accordingly.
You can add error handling to your script and set up email notifications. For now, you can manually check the backup folder to ensure files are being created regularly.
Yes! The backup contains all your data and can be restored to any server with Docker and n8n installed. This is perfect for migrating to a new VPS or setting up a development environment.
Keep at least 30 days of backups. You can add a cleanup script to automatically delete backups older than 30 days to save storage space.