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
first clone the project
git clone https://github.com/ImMohammad20000/marzban-backup.git && cd marzban-backupnow create .env file and configure it.
mv .env.example .envnano .env- set
BOT_TOKENto your bot's API Token - set
CHAT_IDto your Telegram account's numeric ID, you can get your ID from @userinfobot - if you want to use proxy for connect to telegram uncomment
PROXY_URLand set a socks5 or http proxy - set
TZto your time zone, by default set toAsia/Tehran CRON_JOBuse 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.jsonnano server_list.json{
"servers": [
{
"host": "host",
"port": 22,
"user": "user",
"pass": "pass",
"db_type": "mysql",
"db_user": "root",
"db_password": "password",
"database_name": "marzban",
"db_contaner_name": "marzban-mysql-1",
"exclude": [
"mysql"
],
"var_files": "/var/lib/marzban/",
"opt_files": "/opt/marzban/"
}
]
}set db_type to mysql or mariadb to enable database backup
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",
"db_type": "mariadb",
"db_user": "root",
"db_password": "password",
"database_name": "marzban",
"db_contaner_name": "marzban-mysql-1",
"exclude": [
"mysql"
],
"var_files": "/var/lib/marzban/",
"opt_files": "/opt/marzban/"
},
{
"host": "host2",
"port": 22,
"user": "user2",
"pass": "pass2",
"db_type": "mysql",
"db_user": "root",
"db_password": "password",
"database_name": "marzban",
"db_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 -dto test bot use /backup command
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
to update the project just clone the repository again.
If the generated backup file is larger than 50 MB, the bot will automatically split it into 50 MB parts and send each part separately.
To restore the original marzban-backup.zip from the parts use one of the following methods:
- Linux: run
cat marzban-backup.zip.part* > marzban-backup.zipinside the folder that contains the parts. - Windows: in a command prompt run
copy /b marzban-backup.zip.part1+marzban-backup.zip.part2+... marzban-backup.zipor use a tool like 7-Zip to combine them.