Skip to content
AsanFillterPublic

About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 

Repository files navigation

MarzPort

Version License

Migrate users from a Marzban database backup into a running PasarGuard instance.

Proxy UUIDs and passwords are carried over as-is, so existing subscription links continue to work after migration without any client-side changes.


Requirements

  • A full Marzban SQL dump (exported via phpMyAdmin, mariadb-dump, or mysqldump)
  • PasarGuard running with a MariaDB or MySQL container
  • The target admin account must already exist in PasarGuard

Quick Start

Download the script to your server:

curl -O https://raw.githubusercontent.com/AsanFillter/MarzPort/master/marzport.sh && chmod +x marzport.sh

Then open marzport.sh, fill in the configuration section, and run it:

bash marzport.sh

Configuration

Open marzport.sh and fill in the values at the top:

MYSQL_ROOT_PASS=""      # MYSQL_ROOT_PASSWORD from your .env
MARZBAN_ADMIN=""        # Admin username as it appears in the Marzban backup
PASARGUARD_ADMIN=""     # Admin username in PasarGuard (can be the same)
BACKUP_FILE=""          # Full path to the Marzban SQL dump on this server
DB_CONTAINER=""         # MariaDB/MySQL Docker container name
TARGET_DB="pasarguard"  # PasarGuard database name (default: pasarguard)

# Optional — required for automatic node sync after migration
PASARGUARD_URL=""       # e.g. https://panel.example.com
SUDO_USERNAME=""        # a sudo admin username
SUDO_PASSWORD=""        # that sudo admin's password

To find your container name:

docker ps

The script will show a summary of how many users will be migrated and ask for confirmation before making any changes.

What it does

  1. Imports the Marzban SQL backup into a temporary database
  2. Looks up the admin IDs in both Marzban and PasarGuard
  3. Temporarily disables the admin account to prevent external bots from deleting newly migrated users during the process
  4. Inserts all users, converting Marzban's schema to PasarGuard's format
  5. Assigns users to the first available group in PasarGuard
  6. Re-enables the admin account
  7. (If API credentials are set) Calls the PasarGuard API to disable then re-enable all migrated users, which pushes their configs to all connected nodes
  8. Updates the admin's traffic stats and drops the temporary database

If PASARGUARD_URL, SUDO_USERNAME, and SUDO_PASSWORD are not set, the node sync step is skipped. In that case, restart PasarGuard manually after migration:

pasarguard restart

Notes

  • Users that already exist in PasarGuard (matched by username) are skipped — safe to run multiple times
  • Supports MariaDB and MySQL databases
  • If the script fails at any point, the admin account is automatically re-enabled

About

No description, website, or topics provided.

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages