Skip to content

ImMohammad20000/marzban-backup

Repository files navigation

Marzban-backup

a simple bot for get full backup of Marzban pannel

this bot use ssh to download all files from the server so it can be use on iran serveers

How to run

first clone the project

git clone https://github.com/ImMohammad20000/marzban-backup.git && cd marzban-backup

now create .env file and configure it.

mv .env.example .env
nano .env
  1. set BOT_TOKEN to your bot's API Token
  2. set CHAT_ID to your Telegram account's numeric ID, you can get your ID from @userinfobot
  3. if you want to use proxy for connect to telegram uncomment PROXY_URL and set a socks5 or http proxy
  4. set TZ to your time zone, by default set to Asia/Tehran
  5. CRON_JOB use to schedule send backups, by default send backups every hour moore info

then save the changes

It's time to create server_list.json file and configure oure ssh login info

mv server_list.json.example server_list.json
nano server_list.json
{
  "servers": [
    {
      "host": "host",
      "port": 22,
      "user": "user",
      "pass": "pass",
      "is_mysql_DB": false, 
      "mysql_user": "root",
      "mysql_password": "password",
      "database_name": "marzban",
      "mysql_contaner_name": "marzban-mysql-1",
      "exclude": [
        "mysql"
      ],
      "var_files": "/var/lib/marzban/",
      "opt_files": "/opt/marzban/"
    }
  ]
}

if you use mysql database for your pannel set "is_mysql_DB" flag true

if you don't want get backup of some folders or files use exclude list

bot support multiple panel if you have another panel you can use this json

{
  "servers": [
    {
      "host": "host",
      "port": 22,
      "user": "user",
      "pass": "pass",
      "is_mysql_DB": false, 
      "mysql_user": "root",
      "mysql_password": "password",
      "database_name": "marzban",
      "mysql_contaner_name": "marzban-mysql-1",
      "exclude": [
        "mysql"
      ],
      "var_files": "/var/lib/marzban/",
      "opt_files": "/opt/marzban/"
    },
    {
      "host": "host2",
      "port": 22,
      "user": "user2",
      "pass": "pass2",
      "is_mysql_DB": true, 
      "mysql_user": "root",
      "mysql_password": "password",
      "database_name": "marzban",
      "mysql_contaner_name": "marzban-mysql-1",
      "exclude": [
        "mysql"
      ],
      "var_files": "/var/lib/marzban/",
      "opt_files": "/opt/marzban/"
    }
  ]
}

then save the changes

now run this command for start bot

docker compose up -d

to test bot use /backup command

Modify .env or json files

if you want to edit .env or server_list.json after you save changes you have to use docker compose down and docker compose up --build -d for re-build docker contaner

Update

to update the project just clone the repository again.

About

a simple bot for get full backup of marzban pannel

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published