Simple database migration tool for PasarGuard data between PostgreSQL, MySQL/MariaDB, and SQLite.
- Python 3.8+
uv(https://github.com/astral-sh/uv)
Install uv (Linux/macOS):
curl -LsSf https://astral.sh/uv/install.sh | sh
source $HOME/.local/bin/env- Back up the source database.
- Install and run PasarGuard on the target database with the same app version as source.
- Wait until PasarGuard completes its own DB migrations.
- Prepare migration tool:
git clone https://github.com/PasarGuard/db-migratons.git
cd db-migratons
uv sync
chmod +x migrate.sh- Run interactive migration:
./migrate.sh- In wizard: choose source, enter target DB URL, review summary, confirm with
yes. - Verify users, groups, settings, and subscriptions in panel/API.
Config file mode:
cp config.example.yml config.yml
uv run migrations/universal.py --config config.ymlDirect CLI mode:
./migrate.sh <source> --to <type> --db <target_url> [--exclude-tables <tables>]PostgreSQL:
postgresql+asyncpg://username:password@host:port/database
MySQL/MariaDB:
mysql+pymysql://username:password@host:port/database
SQLite:
sqlite:///path/to/database.db
- Full config template: config.example.yml
- MySQL -> PostgreSQL example: config.mysql-to-postgres.yml
- PostgreSQL -> MySQL example: config.postgres-to-mysql.yml
- Migrator script: migrations/universal.py
- Migration clears target data after interactive confirmation.
- Use
--exclude-tablesfor log/history tables if needed.
- GitHub: https://github.com/PasarGuard/db-migratons
- Telegram: https://t.me/PasarGuardGP
- Russian: docs/README.ru.md
- Chinese: docs/README.zh.md
- Persian (Farsi): docs/README.fa.md