Sign inSign up

zyetta/mega-sync

By zyetta

Updated 7 months ago

A Docker container for MEGAcmd (Mega.nz) designed for ARM64 and AMD64 devices.

Image
Databases & storage
0

4.0K

zyetta/mega-sync repository overview

MEGAcmd Docker with 2FA Support (Multi-Arch)

Github Repo: https://github.com/zyetta/mega-container-client

A Docker container for MEGAcmd (Mega.nz) designed for ARM64 (Apple Silicon, Raspberry Pi) and AMD64 (Intel/AMD) devices.

It handles:

  • 2FA Authentication: Persists session via volumes so you only login once.
  • Auto-Sync: Automatically configures sync pairs using environment variables.
  • Auto-Healing: Checks sync status on container restarts.
  • Monitoring & Alerts: Logs transactions and sends Gotify alerts on errors.

Quick Start

1. Create docker-compose.yml
services:
  mega:
    image: zyetta/mega-sync:latest
    container_name: mega-sync
    restart: unless-stopped
    environment:
      # Pair 1
      - SYNC_LOCAL_1=/data/documents
      - SYNC_REMOTE_1=/CloudDrive/Documents
      # Pair 2
      - SYNC_LOCAL_2=/data/photos
      - SYNC_REMOTE_2=/CloudDrive/Photos
      
      # Monitoring (Optional)
      - GOTIFY_URL=https://gotify.example.com
      - GOTIFY_TOKEN=your_app_token
    volumes:
      # CONFIG: Stores your login session (CRITICAL)
      - ./mega-session:/root/.megaCmd
      # DATA: Your local folders to sync
      - ./my-documents:/data/documents
      - ./my-photos:/data/photos
2. First Run (Login)

Because MEGA requires 2FA, you cannot login via environment variables. You must do it interactively one time.

Start the container:

docker compose up -d

Enter the container:

docker exec -it mega-sync bash

Login manually:

mega-login [email protected] "your_password" --auth-code=123456

Wait for the login to succeed and fetch your file list.

Exit the container:

exit
3. Activate Sync

Now that you are logged in, restart the container. The startup script will detect your session and automatically configure the sync folders defined in your environment variables.

docker compose restart mega-sync

Configuration

Environment Variables

You can add as many sync pairs as needed by incrementing the number (up to 10 by default).

VariableDescription
SYNC_LOCAL_XThe path inside the container (mapped to your host)
SYNC_REMOTE_XThe path on your MEGA Cloud Drive
GOTIFY_URL(Optional) URL of your Gotify server
GOTIFY_TOKEN(Optional) Gotify Application Token
Volumes
VolumeDescription
/root/.megaCmdRequired. Stores session ID and cache. Map this to a host folder to survive restarts.

Tag summary

Content type

Image

Digest

sha256:882caa862

Size

95.1 MB

Last updated

7 months ago

docker pull zyetta/mega-sync