Marzban panel vps ပျက်သွားရင် user မပျောက် အောင် gdrive ပေါ် daily auto backup လုပ်နည်း
ဒီ guide က VPS ထဲက /opt/marzban နဲ့ /var/lib/marzban ကို
တစ်နေ့တစ်ခါ (Asia/Yangon ည ၂ နာရီ) backup လုပ်ပြီး
Google Drive ထဲက marzban (မိမိနှစ်သက်ရာ folder name ပေးနိုင်) ထဲကို တင်ပေးမှာပါ။
Backup ဟောင်းတွေကိုလည်း ၃ ရက်ကျော်သွားရင် auto delete လုပ်ပေးမှာပါ။
မိမိ VPS ကိုစိတ်မချရင်တော့ Auto Daily Backup လုပ်ထားတာကောင်းပါတယ်။
VPS အဟောင်းမပျက်ဘဲ manual အနေနဲ့ Backup / Restore လုပ်နည်း (Manual)
- VPS အဟောင်းမှာ Marzban ကို ခဏ down/stop လုပ်ပါ။
-
SFTP နဲ့ အောက်က folder ၂ခုကို download ယူပါ —
/opt/marzban/var/lib/marzban
- cloudflare မှာ record လုပ်ထားတဲ့ domain မှာ vps အဟောင်း ip အစား အသစ် ip ဖြင့် အရင်ချိန်းပါ။ VPS အသစ်မှာ Marzban panel ကို install လုပ်ပြီး ESSL နဲ့ domain ထည့်ပါ။ .env ဘာမှ ပြင်စရာမလိုပါ (template / setting တွေကိုလည်း သင့်တော်သလို set လုပ်ပါ)
- Download ယူထားတဲ့ folder ၂ခုကို VPS အသစ်ထဲကို လမ်းကြောင်းအမှန်အတိုင်းSFTP နဲ့ upload ပြန်တင်ပါ။
- ပြီးရင် Marzban ကို restart လုပ်ပါ။ vps အဟောင်းကပုံစံ အတိုင်း အားလုံးပြန်အလုပ်လုပ်လာပါလိမ့်မယ်။
မှတ်ချက် (အရေးကြီး):
Subscription link ကို အသုံးပြုနေသူတွေက link မပြောင်းပဲဆက်သုံးလို့ရနေမှာပါ
(Shadowsocks ss:// link ကို Outline နဲ့သုံးနေသူများ Key မပြောင်းပဲ ဆက်အသုံးပြုလို့ရအောင်) —
Backup ယူမယ့် VPS အဟောင်းရဲ့ Marzban panel ထဲမှာ
Main Server (Shadowsocks) host setting ရဲ့ IP address နေရာမှာ
Cloudflare မှာ record လုပ်ထားတဲ့ domain ကို ထည့်ပေးထားရပါမယ်။
(Node server များ မပါဝင်ပါ)
1) Auto Back လုပ်မယ့် vps မှာ Source folder တွေရှိ/မရှိ စစ်
ls -la /opt/marzban /var/lib/marzban
Backup မလုပ်ခင် လိုအပ်သော host setting inbound tamplates အားလုံးကို လိုအပ်သလို အရင် ပြင်ဆင်ထားပါ
အပေါ်က command မှာ No such file or directory ထွက်ရင်
VPS ထဲမှာ folder path က တခြားနာမည်ဖြစ်နိုင်လို့ script ထဲက path ကိုပြင်ရမယ်။
2) rclone + Google Drive remote ချိတ်
2.1 rclone install
sudo apt update sudo apt install -y rclone
2.2 rclone config (Interactive)
rclone config (Headless VPS) — Google Drive Remote Setup (Step-by-step)
ဒီအဆင့်တွေက VPS (browser မရှိတဲ့ headless machine) မှာ gdrive remote တစ်ခုလုပ်ပြီး
Windows / Phone (browser ပါတဲ့ device) ကနေ config_token ကိုယူပြီး paste လုပ်တာပါ။
1) rclone config ကိုစ
rclone config
ပထမဆုံး ဒီမေးခွန်းလာမယ် — New remote လုပ်မယ်:
No remotes found, make a new one? n) New remote s) Set configuration password q) Quit config n/s/q> n
n ရိုက်ပြီး Enter ခေါက်ပေးပါ
2) Remote name ပေး
Enter name for new remote. name> gdrive
Remote name က နောက်မှာ command သုံးမယ့်အခါ gdrive: လို့ခေါ်မယ်။
(colon : မပါရင် local folder လို့ထင်တတ်)
3) Storage type ရွေး (Google Drive)
Storage> drive
drive လို့ရေးပြီး Enter (သို့) list ထဲက drive number ကိုရွေး
4) client_id / client_secret (မရှိရင် blank)
Enter a value. Press Enter to leave empty. client_id> (enter) Enter a value. Press Enter to leave empty. client_secret> (enter)
ပုံမှန်အသုံးပြုရင် blank ချန်ထားလို့ရပါတယ်။ Google API custom app မလုပ်ထားရင် မထည့်ပါနဲ့။
5) Scope ရွေး
scope> 1
အများအားဖြင့် 1 (Full access) ကိုရွေးပါ — (delete/cleanup လုပ်ဖို့လို)
6) service_account_file (မသုံးရင် blank)
Enter a value. Press Enter to leave empty. service_account_file> (enter)
Service Account (SA) သုံးမယ်ဆိုမှ JSON path ထည့်ရတာပါ။ ပုံမှန် Google account authorize လုပ်မယ်ဆို Enter ပဲနှိပ်ပြီး blank ချန် ပါ။
7) Advanced config (မလိုရင် No)
Edit advanced config? y) Yes n) No (default) y/n> n
n ရိုက်ပြီး Enter
8) Use auto config? (VPS headless ဆို No)
Use auto config? * Say Y if not sure * Say N if you are working on a remote or headless machine y) Yes (default) n) No y/n> n
VPS (browser မရှိ) ဖြစ်လို့ n ရိုက်ပြီး Enter
pc မှာဆိုရင် reclone application ဒေါင်းထားဖို့ လိုအပ်ပါတယ်
Windows မှာ rclone ဒေါင်းပြီး VPS ကို authorize token ထုတ်ရန်
အောက်က link တွေထဲက တစ်ခုခုကနေ Windows 64-bit (amd64) zip ကို ဒေါင်းပြီး unzip လုပ်ပါ။
ပြီးရင် PowerShell ကနေ .\rclone.exe authorize ... နဲ့ token JSON ထုတ်ပြီး VPS မှာ paste လုပ်နိုင်ပါတယ်။
✅ Download Links (Official)
How to run (Windows PowerShell)
- ZIP ကို unzip လုပ်ပြီး
rclone.exeရှိတဲ့ folder ထဲဝင်ပါ - အဲဒီ folder ထဲမှာ Shift+right click နှိပ်ပြီး Open PowerShell window hear ကိုဖွင့်ပါ
- အောက်က command ကို run လုပ်ပါ (current folder ထဲက exe မို့
.\ပါရမယ်)
.\rclone.exe authorize "drive" "eyJzY29wZSI6ImRyaXZlIn0"
Browser ဖွင့်လာပြီး Google account authorize လုပ်ပေးရပါမယ် ပြီးရင် powershell terminal ထဲမှာ
token JSON တစ်ခု output ထွက်လာမယ်။ အဲဒီ JSON ကိုလုံးဝ အပြည့်အစုံ copy လုပ်ပြီး VPS ထဲက
rclone config မှာ token paste လုပ်ပါ။
Install/Usage docs (optional)
9) config_token (Windows က token JSON ကို paste)
ဒီနေရာက အရေးကြီးဆုံးပါ။ rclone က browser ပါတဲ့ device ပေါ်မှာ token ထုတ်ပြီး အဲဒီ JSON အပြည့်အစုံကို VPS ထဲမှာ paste လုပ်ခိုင်းတာပါ။
rclone က ဒီလိုညွှန်မယ်:
Option config_token.
Execute the following on the machine with the web browser:
rclone authorize "drive" "eyJzY29wZSI6ImRyaXZlIn0"
Then paste the result.
Enter a value.
config_token>
Windows PowerShell (browser ပါတဲ့ PC) မှာ run:
.\rclone.exe authorize "drive" "eyJzY29wZSI6ImRyaXZlIn0"
Google login/Allow လုပ်ပြီးရင် PowerShell ထဲမှာ token JSON ထွက်လာမယ်။
အဲဒီ JSON ကို အစကနေ အဆုံးထိ ( { ကနေ } ထိ )
copy လုပ်ပြီး VPS ရဲ့ config_token> နောက်မှာ paste လုပ်ပါ။
✅ Paste လုပ်ရမယ့်ပုံစံ (ဥပမာ):
eyJ0b2tlb....ifQ== (အပြည့်အစုံ)
အဆုံးမှာ <---End paste လို့ပြလာရင် paste ပြီးသွားပြီဆိုတဲ့အဓိပ္ပါယ်ပါ။
10) Shared Drive (Team Drive) သုံးမသုံး
Configure this as a Shared Drive (Team Drive)? y) Yes n) No (default) y/n> n
Shared Drive မသုံးရင် n ရိုက် Enter
11) Remote ကိုသိမ်း
Keep this "gdrive" remote? y) Yes this is OK (default) e) Edit this remote d) Delete this remote y/e/d> y
y ရိုက် Enter (save)
12) Quit config
Current remotes: Name Type ==== ==== gdrive drive e) Edit existing remote n) New remote d) Delete remote r) Rename remote c) Copy remote s) Set configuration password q) Quit config e/n/d/r/c/s/q> q
q ရိုက် Enter
Troubleshooting Quick Fix
- Paste မအောင်မြင်: token JSON ကို
{ ... }အပြည့်အစုံ copy/paste လုပ်ပါ - Wrong remote name:
rclone listremotesနဲ့နာမည်စစ်ပြီးNAME:နဲ့ခေါ်ပါ - Shared Drive သုံးမသုံး: မသုံးရင် အမြဲ
n
Phone (Termux) နဲ့ rclone Google Drive Authorize → VPS မှာ token paste လုပ်နည်း
ဒီ guide က ဖုန်း (Android) + Termux ကိုသုံးပြီး Google Drive ကို authorize လုပ်ကာ
token JSON ထုတ်ပြီး၊ အဲဒီ token ကို VPS ထဲက rclone config မှာ
paste လုပ်ပြီး remote (gdrive) ချိတ်တာအတွက်ပါ။
1) Termux ထဲမှာ rclone သွင်း
pkg update -y && pkg upgrade -y pkg install -y rclone termux-api rclone version
OK ဖြစ်ရင် rclone version info ထွက်လာမယ်။
2) Termux ထဲမှာ Google Drive authorize လုပ် (token ထုတ်)
အောက်က command ကို Termux ထဲမှာ run လုပ်ပါ:
rclone authorize "drive" "eyJzY29wZSI6ImRyaXZlIn0"
Run လုပ်ပြီးရင် Termux ထဲမှာ ဒီလိုပေါ်လာတတ်ပါတယ်:
http://127.0.0.1:xxxxx/auth?state=..... 2026/01/14 11:31:37 NOTICE: Log in and authorize rclone for access 2026/01/14 11:31:37 NOTICE: Waiting for code.
အောက်ကအဆင့်တွေအတိုင်းလုပ်ရန်:
- Termux မှာပြတဲ့
http://127.0.0.1:XXXXX/auth?state=...link ကို copy လုပ်ပါ - ဖုန်း browser (Chrome) မှာ paste လုပ်ပြီးဖွင့်ပါ
- Google account နဲ့ login ဝင်ပြီး Allow လုပ်ပါ
- Authorize ပြီးတာနဲ့ Termux ထဲမှာ token JSON output ထွက်လာမယ်
⚠️ အရေးကြီး: token JSON ကို အစကနေ အဆုံးထိ ( { ကနေ } ထိ )
အပြည့်အစုံ copy လုပ်ရပါမယ်။
အခု token ကို vps terminal မှာ paste လုပ်ပေးလိုက်ပါ
Troubleshooting (မဖြစ်ရင်)
- Link မဖွင့်ရ: browser မှာ
http://127.0.0.1:PORT/...ကို paste လုပ်ပြီးဖွင့်ပါ - Token မထွက်: browser မှာ Allow မလုပ်ရသေးတာဖြစ်နိုင် — Allow ပြီးမှ Termux သို့ပြန်ကြည့်ပါ
- Paste မအောင်မြင်: token JSON ကို
{...}အပြည့်အစုံ copy/paste လုပ်ပါ - Remote မတွေ့:
rclone listremotesနဲ့ remote name စစ်ပြီးNAME:နဲ့ခေါ်ပါ
2.3 Drive ချိတ်ပြီးပြီလား စမ်း
rclone lsd gdrive:
OK ဆိုရင် Google Drive ထဲက folder list တွေ ပြလာမယ်။
3) Google Drive ထဲ target folder ဆောက်
rclone mkdir "gdrive:marzban"
ကိုလိုချင်တဲ့ folder name အတိုင်း marzban ထဲကို upload လုပ်ချင်တာမို့ ဒီ folder ရှိဖို့လိုပါတယ်။
4) Backup script ရေးပေးထားရပါမယ်
Script location: /usr/local/bin/marzban_gdrive_backup.sh
sudo nano /usr/local/bin/marzban_gdrive_backup.sh
အောက်က script ကို အပြည့်အစုံ paste လုပ်ပါ:
#!/usr/bin/env bash set -euo pipefail # ========================= # Marzban Backup -> Google Drive # Drive Structure: # gdrive:marzban// / # Local Structure: # /opt/backups/marzban/ / / # Retention: # Remote: delete files older than 72h (3 days) # Local : delete files older than 3 days # ========================= TS="$(date '+%Y-%m-%d_%H-%M-%S')" DATE_DIR="$(date '+%Y-%m-%d')" HOST="$(hostname -s)" # Source folders SRC1="/opt/marzban" SRC2="/var/lib/marzban" # Local backup base WORKBASE="/opt/backups/marzban" WORKDIR="${WORKBASE}/${HOST}/${DATE_DIR}" # rclone remote + folder REMOTE="gdrive" REMOTE_BASE="marzban" REMOTE_DIR="${REMOTE_BASE}/${HOST}/${DATE_DIR}" # Create local workdir mkdir -p "$WORKDIR" # Validate sources for d in "$SRC1" "$SRC2"; do if [ ! -d "$d" ]; then echo "ERROR: missing folder: $d" exit 1 fi done # Archive file name ARCHIVE="${WORKDIR}/${HOST}_marzban_${TS}.tar.gz" # Create tarball (absolute paths preserved) # NOTE: tar paths are relative to / tar -czf "$ARCHIVE" -C / \ "opt/marzban" \ "var/lib/marzban" # Create checksum (for integrity verification) sha256sum "$ARCHIVE" > "${ARCHIVE}.sha256" # Ensure Drive folder exists rclone mkdir "${REMOTE}:${REMOTE_DIR}" # Upload archive + checksum rclone copy "$ARCHIVE" "${REMOTE}:${REMOTE_DIR}" --transfers 2 --checkers 4 rclone copy "${ARCHIVE}.sha256" "${REMOTE}:${REMOTE_DIR}" # Remote retention: remove items older than 72 hours under gdrive:marzban # This deletes old backup files; then removes empty directories. rclone delete "${REMOTE}:${REMOTE_BASE}" --min-age 72h --drive-use-trash=false rclone rmdirs "${REMOTE}:${REMOTE_BASE}" --leave-root # Local retention: keep only 3 days find "$WORKBASE" -type f -mtime +3 -name "*_marzban_*" -delete find "$WORKBASE" -type d -empty -delete echo "OK: backup uploaded: ${ARCHIVE}"
Save / Exit (nano)
Save: Ctrl + O → Enter
Exit: Ctrl + X
Permission ပေး:
sudo chmod 700 /usr/local/bin/marzban_gdrive_backup.sh
4.1 manual တစ်ခါ run စမ်း
sudo /usr/local/bin/marzban_gdrive_backup.sh
4.2 Drive ထဲ backup file ရောက်လာလားစစ်ပါ
rclone lsl "gdrive:marzban" | tail -n 20
OK ဖြစ်ရင် .tar.gz နဲ့ .sha256 ဖိုင်တွေ Drive ထဲမှာ မြင်ရမယ်။
.sha256 က backup ဖိုင်ကိုအကောင်းတိုင်းဖြစ်ဖို့ကို စစ်ဖို့ checksum verification ဖိုင်ပါ။
5) Asia/Yangon timezone ထားပေးပါမယ်
sudo timedatectl set-timezone Asia/Yangon timedatectl | grep "Time zone"
6) systemd service + timer (Daily 02:00) အလုပ်လုပ်ဖို့ script ထည့်ပါမယ်
6.1 Service file
sudo nano /etc/systemd/system/marzban-gdrive-backup.service
ဒီအတိုင်း paste:
[Unit] Description=Backup Marzban folders to Google Drive Wants=network-online.target After=network-online.target [Service] Type=oneshot ExecStart=/usr/local/bin/marzban_gdrive_backup.sh
Save / Exit (nano)
Save: Ctrl + O → Enter
Exit: Ctrl + X
6.2 Timer file
sudo nano /etc/systemd/system/marzban-gdrive-backup.timer
ဒီအတိုင်း paste:
[Unit] Description=Run Marzban backup daily at 02:00 [Timer] OnCalendar=*-*-* 02:00:00 Persistent=true RandomizedDelaySec=300 [Install] WantedBy=timers.target
Save / Exit (nano)
Save: Ctrl + O → Enter
Exit: Ctrl + X
6.3 Enable + Start
sudo systemctl daemon-reload sudo systemctl enable --now marzban-gdrive-backup.timer
6.4 Next run / status စစ်
sudo systemctl list-timers --all | grep marzban systemctl status marzban-gdrive-backup.timer --no-pager
Active (waiting) နဲ့ Trigger: ... 02:xx လို့ပြရင် timer OK ပါ။
RandomizedDelaySec=300 ကြောင့် 02:00 တိတိကျကျမဟုတ်ဘဲ 02:00 ~ 02:05 အတွင်း random လုပ်နိုင်ပါတယ်။
တိတိကျကျ 02:00:00 လိုချင်ရင် ဒီလိုင်းကို ဖယ်လိုက်ပါ။
7) Log စစ် (manual run နဲ့ log ပေါ်အောင် စမ်း)
sudo systemctl start marzban-gdrive-backup.service journalctl -u marzban-gdrive-backup.service -n 80 --no-pager
Log ထဲမှာ OK: backup uploaded... လို့ထွက်ရင် အကုန် OK ပါ။
8) Restore
Restore မလုပ်ခင် service/docker မှာ marzban ကို ခဏရပ်ထားရင် ပိုလုံခြုံပါတယ်။
vps အသစ်မှာ marzban panel script, essl domain script, template သုံးထားရင် template script တွေ အရင်ဆုံး run ထားဖို့လိုပါတယ်။ ပြီးရင် vps အဟောင်းကနေ google drive ပေါ် Auto backup လုပ်ထားတဲ့ .tar.gz ဖိုင်ကို unzip လုပ်ပြီး သက်ဆိုင်ရာ folder အလိုက် vps အသစ်ပေါ်မှာ upload လုပ်လိုက်ရုံပါပဲ။ marzban restart ဖြင့် terminal မှာ run ပေးလိုက်ရင်ရပါပြီ
Troubleshooting
- rclone config မတွေ့ → remote name မှန်လား စစ်:
rclone config file,rclone listremotes - permission error → script ကို
sudoနဲ့ run လုပ်ပါ:sudo /usr/local/bin/... - folders missing →
/opt/marzban//var/lib/marzbanpaths ကို VPS အလိုက်ပြင်ပါ - Drive upload fail →
rclone lsd gdrive:နဲ့ auth expire ဖြစ်နေလား စစ်ပါ
rclone ပြန်ဖြတ်ခြင်ရင်
sudo apt update sudo apt purge -y rclone sudo apt autoremove --purge -y sudo rm -rf /root/.config/rclone /root/.rclone.conf