Quick Links
  • Smarthome
  • Business
  • Blogging
  • WordPress
  • Marketing
  • Make Money
AI
View Posts
AI for SEO: Best uses of Artificial Intelligence
Blogging
View Posts
Business Software
View Posts
Help
View Posts
Make Money
View Posts
Marketing
View Posts
Smarthome
View Posts
WordPress
View Posts
Suyash Rai
  • Smarthome
  • Business
  • Blogging
  • WordPress
  • Marketing
  • Make Money
  • Marketing

How I Seamlessly Migrated My Entire Docker Stack (Supabase, n8n, Baserow, Redis, MinIO, PostgreSQL) to a New Server

  • 3 minute read
Total
0
Shares
0
0
0

Migrating an entire stack of Docker containers that includes critical services like Supabase, n8n, Baserow, MinIO, Redis, and PostgreSQL can be terrifying.

I’ve done it. The first time, it took me hours, with lots of data loss, broken volumes, and missing .env values. But now, I’ve built a battle-tested system that makes the move safe, fast, and complete.

In this guide, I’ll walk you through how I:

  • 🔄 Backed up containers, volumes, Compose files, and environment variables
  • 🔹 Migrated everything including Portainer stacks
  • ⚙️ Recreated all my services: supabase, baserow, n8n, redis, minio, postgresql, and more
  • ✅ Wrote 2 easy shell scripts to make this process automatic

Let’s dive in.


🚀 My Stack: What I Needed to Migrate

Here’s a snapshot of my Docker environment:

  • Supabase (with Postgres + Auth)
  • n8n (workflow automation)
  • Baserow (no-code database)
  • MinIO (S3-compatible storage)
  • Redis (session caching)
  • PostgreSQL (independent instances)
  • Portainer (for managing stacks)

These are all running as Docker Compose stacks, mostly deployed through Portainer. Data is stored in named volumes. Environment variables are defined either inline or in .env files.


📁 Folder Structure I Use

All backups and scripts live under a single directory:

~/docker-backup/
├── backup.sh        # Backup script
├── restore.sh       # Restore script
├── volumes/         # Docker volume backups (tar.gz)
├── compose/         # docker-compose.yml & .env files
├── images.tar       # All Docker images
├── logs/            # Backup/restore logs

💾 The Backup Script (backup.sh)

#!/bin/bash
set -e

BASE_DIR="$(cd \"$(dirname \"${BASH_SOURCE[0]}\")\" && pwd)"
VOLUME_BACKUP_DIR="$BASE_DIR/volumes"
COMPOSE_BACKUP_DIR="$BASE_DIR/compose"
LOG_DIR="$BASE_DIR/logs"
PROJECTS_DIR=~/docker-projects

mkdir -p "$VOLUME_BACKUP_DIR" "$COMPOSE_BACKUP_DIR" "$LOG_DIR"
NOW=$(date +"%Y-%m-%d_%H-%M-%S")
LOG_FILE="$LOG_DIR/backup_$NOW.log"

echo "📦 Backing up Docker volumes..." | tee -a "$LOG_FILE"
for vol in $(docker volume ls -q); do
  echo "→ $vol" | tee -a "$LOG_FILE"
  docker run --rm -v "$vol":/volume -v "$VOLUME_BACKUP_DIR":/backup alpine \
    tar czf "/backup/${vol}.tar.gz" -C /volume . >> "$LOG_FILE" 2>&1
done

echo "📸 Saving Docker images..." | tee -a "$LOG_FILE"
docker save $(docker images -q | uniq) -o "$BASE_DIR/images.tar"

echo "📃 Backing up Compose & Env files..." | tee -a "$LOG_FILE"
rsync -av --include='*/' --include='docker-compose.yml' --include='.env' --exclude='*' "$PROJECTS_DIR/" "$COMPOSE_BACKUP_DIR/" >> "$LOG_FILE"

echo "✅ Backup complete!" | tee -a "$LOG_FILE"

🚪 The Restore Script (restore.sh)

#!/bin/bash
set -e

BASE_DIR="$(cd \"$(dirname \"${BASH_SOURCE[0]}\")\" && pwd)"
VOLUME_ARCHIVES_DIR="$BASE_DIR/volumes"
COMPOSE_DIR="$BASE_DIR/compose"
LOG_DIR="$BASE_DIR/logs"

mkdir -p "$LOG_DIR"
NOW=$(date +"%Y-%m-%d_%H-%M-%S")
LOG_FILE="$LOG_DIR/restore_$NOW.log"

echo "📦 Restoring Docker volumes..." | tee -a "$LOG_FILE"
for archive in "$VOLUME_ARCHIVES_DIR"/*.tar.gz; do
  vol_name=$(basename "$archive" .tar.gz)
  echo "→ Volume: $vol_name" | tee -a "$LOG_FILE"
  docker volume create "$vol_name"
  docker run --rm -v "$vol_name":/volume -v "$VOLUME_ARCHIVES_DIR":/backup alpine \
    tar xzf "/backup/${vol_name}.tar.gz" -C /volume >> "$LOG_FILE" 2>&1
done

echo "📸 Loading Docker images..." | tee -a "$LOG_FILE"
docker load -i "$BASE_DIR/images.tar" >> "$LOG_FILE" 2>&1

echo "🚀 Starting services..." | tee -a "$LOG_FILE"
find "$COMPOSE_DIR" -name 'docker-compose.yml' | while read -r compose_file; do
  stack_dir=$(dirname "$compose_file")
  echo "▶️ $stack_dir" | tee -a "$LOG_FILE"
  (cd "$stack_dir" && docker-compose up -d >> "$LOG_FILE" 2>&1)
done

echo "✅ Restore complete!" | tee -a "$LOG_FILE"

🛌 Step-by-Step Workflow

On Old Server:

cd ~/docker-backup
bash backup.sh

Transfer to New Server:

scp -r ~/docker-backup user@new-server:~/

On New Server:

cd ~/docker-backup
bash restore.sh

📊 Notes for Supabase, Baserow, and Others

  • Supabase: Ensure that your Postgres and storage volumes are named and backed up.
  • MinIO: Its /data volume must be persistent.
  • Redis/PostgreSQL: All data lives in volumes (e.g., /data, /var/lib/postgresql).
  • n8n: Store its .env file carefully. Webhook URLs may change post-migration.
  • Baserow: Needs BASEROW_PUBLIC_URL and plugin paths preserved.
  • Portainer: Reinstall and re-import stacks using the restored Compose files.

✨ Pro Tips

  • Add cronjob to run backup every night
  • Use docker context to work remotely if needed
  • Store .env files next to each docker-compose.yml for auto-loading

🚀 Future Improvements (Optional)

  • Sync backups to Google Drive or S3
  • Notify via n8n workflow after backup
  • Add encryption for volume tarballs

😎 Final Thoughts

With this setup, I can migrate my entire Docker infrastructure with confidence. Whether I’m switching hosts, rebuilding from scratch, or doing DR testing — it just works.

9 Best Web Hosting for Business Growth & Scaling
Also Read
9 Best Web Hosting for Business Growth & Scaling

If you're using Docker with Supabase, Redis, Baserow, and others, try this out. You’ll save yourself hours of manual work.

Total
0
Shares
Share 0
Tweet 0
Pin it 0
Suyash Rai

Business Consultant, Full Stack Developer

Subscribe

Subscribe now to our newsletter

You May Also Like

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Table of Contents
  1. 🚀 My Stack: What I Needed to Migrate
  2. 📁 Folder Structure I Use
  3. 💾 The Backup Script (backup.sh)
  4. 🚪 The Restore Script (restore.sh)
  5. 🛌 Step-by-Step Workflow
    1. On Old Server:
    2. Transfer to New Server:
    3. On New Server:
  6. 📊 Notes for Supabase, Baserow, and Others
  7. ✨ Pro Tips
  8. 🚀 Future Improvements (Optional)
  9. 😎 Final Thoughts


Hostinger

Ecommerce Marketing Automation


landing page builder

How I Seamlessly Migrated My Entire Docker Stack (Supabase, n8n, Baserow, Redis, MinIO, PostgreSQL) to a New Server

Share
How I Fixed GoodWe Solar Export Not Showing in Home Assistant (Complete Grid Import & Export Setup Guide)

How I Fixed GoodWe Solar Export Not Showing in Home Assistant (Complete Grid Import & Export Setup Guide)

Share
How to Fix The Critical Error in WordPress

How to Fix The Critical Error in WordPress (Step by Step)

Share
How to Fix the Error Establishing a Database Connection in WordPress

How to Fix the Error Establishing a Database Connection in WordPress?

Share

Subscribe

Subscribe now to our newsletter

Suyash Rai
  • Contact
  • Privacy Policy
skipping nine to five

Input your search keywords and press Enter.