You Can Use This Script To Make Backup From .env
, xray_config.json
, docker-compose.yml
, certificates
, templates
And Database
On Telegram And Discord.
- Both MySQL and SQlite3 Are Supported.
First You Need To Install tar
, wget
And curl
.
apt install tar curl wget
Then Change The Directory.
cd /opt/marzban
Make A Folder For Temporary Files.
mkdir backup
- Download The Script.
wget https://raw.githubusercontent.com/M03ED/Marzban_Backup/main/backup.sh
Change Variables If Your File Name Or Location Is Diffrent.
ENV_PATH="/opt/marzban/.env"
DB_NAME="marzban"
CONTAINER_NAME="mysql"
BACKUP_DIR="/opt/marzban/backup"
DOCKER_PATH="/opt/marzban/docker-compose.yml"
CERTS="/var/lib/marzban/certs"
TEMPLATES="/var/lib/marzban/templates"
Set These Variables In .env File Like This.
TELEGRAM_BACKUP_TOKEN = "11111111111:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
TELEGRAM_ADMIN_ID = "11111111111"
BACKUP_INTERVAL_TIME =120 #backup time per minutes
# only for discord
DISCORD_BACKUP_URL = "https://discord.com/api/webhooks/111111111111111111111111/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
You Should Add Execute Permissions To The Script.
chmod +x /opt/marzban/backup.sh
Then Run The Program In nohup
Mode To Stay Active In Background.
nohup /opt/marzban/backup.sh &
- Now You Have Your Backup On Telegram And Discord.
- New File With
nohup.out
Name Gonna Be Created in/opt/marzban
And It Will Record Your Script Log , You Can Delete It When Ever You Want.