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.

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

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

Mastering Email Marketing: Full Guide
Read More
  • 14 min
  • Marketing

Mastering Email Marketing: A Comprehensive Guide for Success

  • Suyash Rai
  • December 18, 2023
AI for SEO: Best uses of Artificial Intelligence
Read More
  • 7 min
  • Marketing
  • AI

Building a Strong Online Brand with AI Website Builders

  • Suyash Rai
  • October 9, 2023
Best Landing Page Builders for Better Leads
Read More
  • 6 min
  • Marketing
  • AI

Elevating Your Local SEO Strategy with AI Website Builders

  • Suyash Rai
  • October 9, 2023
AI-powered Website Builders
Read More
  • 5 min
  • Marketing
  • AI

Revolutionizing Web Design with AI-powered Website Builders

  • Suyash Rai
  • October 9, 2023
off-page-seo
Read More
  • 3 min
  • Marketing
  • AI

Unleashing the Power of Off-Page SEO for Superior Rankings

  • Suyash Rai
  • October 9, 2023
Reddit's Top 25 Picks: The Best Domain Hosting Providers Revealed!
Read More
  • 16 min
  • Marketing

Reddit’s Top 25 Picks: The Best Domain Hosting Providers Revealed!

  • Suyash Rai
  • July 25, 2023
T-Shirt Business: 13 Tips Essential for your Brand Growth
Read More
  • 8 min
  • Marketing

13 Best T-Shirt Business Tips Essential for your Brand Growth

  • Suyash Rai
  • August 23, 2022
10 Best Email Marketing Tools to Save Time & Money
Read More
  • 6 min
  • Business Software
  • Marketing

10 Best Email Marketing Tools to Save Time & Money

  • Suyash Rai
  • June 23, 2022

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
  • 05.07.26
  • 3 min
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)
  • 27.02.26
  • 4 min
Mastering Email Marketing: Full Guide
Mastering Email Marketing: A Comprehensive Guide for Success
  • 18.12.23
  • 14 min
How to Fix The Critical Error in WordPress
How to Fix The Critical Error in WordPress (Step by Step)
  • 19.11.23
  • 4 min
How to Fix the Error Establishing a Database Connection in WordPress
How to Fix the Error Establishing a Database Connection in WordPress?
  • 19.11.23
  • 4 min

Subscribe

Subscribe now to our newsletter

Suyash Rai
  • Contact
  • Privacy Policy
skipping nine to five

Input your search keywords and press Enter.