feat: add scripts for MikroTik PPP user management and Google Drive backup, and update .gitignore to exclude backup folders.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -21,3 +21,6 @@ coverage.xml
|
||||
# Project specific
|
||||
routing-lokal.rsc
|
||||
bgp_sync.log
|
||||
|
||||
# Backup folder - do not commit
|
||||
myBackup/
|
||||
|
||||
43
failed_ppp_users.csv
Normal file
43
failed_ppp_users.csv
Normal file
@@ -0,0 +1,43 @@
|
||||
Username,Status
|
||||
1500020,Authentication Failed
|
||||
81100008,Authentication Failed
|
||||
81100009,Authentication Failed
|
||||
81500005,Authentication Failed
|
||||
81700004,Authentication Failed
|
||||
81700006,Authentication Failed
|
||||
81700007,Authentication Failed
|
||||
81800010,Authentication Failed
|
||||
81900003,Authentication Failed
|
||||
81900004,Authentication Failed
|
||||
82000030,Authentication Failed
|
||||
82000031,Authentication Failed
|
||||
82000036,Authentication Failed
|
||||
82000037,Authentication Failed
|
||||
82000038,Authentication Failed
|
||||
82000039,Authentication Failed
|
||||
82000040,Authentication Failed
|
||||
82000041,Authentication Failed
|
||||
8200006,Authentication Failed
|
||||
8200007,Authentication Failed
|
||||
8200008,Authentication Failed
|
||||
8200010,Authentication Failed
|
||||
8200011,Authentication Failed
|
||||
82100002,Authentication Failed
|
||||
82400002,Authentication Failed
|
||||
82500006,Authentication Failed
|
||||
82700002,Authentication Failed
|
||||
8300004,Authentication Failed
|
||||
83300002,Authentication Failed
|
||||
83300003,Authentication Failed
|
||||
83500002,Authentication Failed
|
||||
83500003,Authentication Failed
|
||||
8400002,Authentication Failed
|
||||
84100002,Authentication Failed
|
||||
84100003,Authentication Failed
|
||||
8500004,Authentication Failed
|
||||
8500008,Authentication Failed
|
||||
8700002,Authentication Failed
|
||||
demangputrakbl,Authentication Failed
|
||||
jayenmecutan,Authentication Failed
|
||||
mologkos@sanga,Authentication Failed
|
||||
purnamaningsih-tebuana,Authentication Failed
|
||||
|
43
failed_ppp_users.xls
Normal file
43
failed_ppp_users.xls
Normal file
@@ -0,0 +1,43 @@
|
||||
Username Status
|
||||
1500020 Authentication Failed
|
||||
81100008 Authentication Failed
|
||||
81100009 Authentication Failed
|
||||
81500005 Authentication Failed
|
||||
81700004 Authentication Failed
|
||||
81700006 Authentication Failed
|
||||
81700007 Authentication Failed
|
||||
81800010 Authentication Failed
|
||||
81900003 Authentication Failed
|
||||
81900004 Authentication Failed
|
||||
82000030 Authentication Failed
|
||||
82000031 Authentication Failed
|
||||
82000036 Authentication Failed
|
||||
82000037 Authentication Failed
|
||||
82000038 Authentication Failed
|
||||
82000039 Authentication Failed
|
||||
82000040 Authentication Failed
|
||||
82000041 Authentication Failed
|
||||
8200006 Authentication Failed
|
||||
8200007 Authentication Failed
|
||||
8200008 Authentication Failed
|
||||
8200010 Authentication Failed
|
||||
8200011 Authentication Failed
|
||||
82100002 Authentication Failed
|
||||
82400002 Authentication Failed
|
||||
82500006 Authentication Failed
|
||||
82700002 Authentication Failed
|
||||
8300004 Authentication Failed
|
||||
83300002 Authentication Failed
|
||||
83300003 Authentication Failed
|
||||
83500002 Authentication Failed
|
||||
83500003 Authentication Failed
|
||||
8400002 Authentication Failed
|
||||
84100002 Authentication Failed
|
||||
84100003 Authentication Failed
|
||||
8500004 Authentication Failed
|
||||
8500008 Authentication Failed
|
||||
8700002 Authentication Failed
|
||||
demangputrakbl Authentication Failed
|
||||
jayenmecutan Authentication Failed
|
||||
mologkos@sanga Authentication Failed
|
||||
purnamaningsih-tebuana Authentication Failed
|
||||
38
pp-user.csv
Normal file
38
pp-user.csv
Normal file
@@ -0,0 +1,38 @@
|
||||
Username password profile
|
||||
1500020 sriyani060325 star_30
|
||||
81100008 sukanta230126 star_30
|
||||
81100009 andika090226 star_30
|
||||
81500005 ana050226 star_30
|
||||
81700004 nopayana130126 star_30
|
||||
81700006 yuni260126 star_30
|
||||
81700007 sri270126 star_30
|
||||
81800010 diana060126 star_30
|
||||
81900003 rismayani050226 star_30
|
||||
81900004 sukarna190226 star_30
|
||||
82000030 nandika290126 star_30
|
||||
82000031 suarmini310126 star_30
|
||||
82000036 suarjana160226 star_30
|
||||
82000037 suprapta190226 star_30
|
||||
82000038 sucika210226 star_30
|
||||
82000039 satria250226 star_30
|
||||
82000040 yudi270226 star_30
|
||||
82000041 hendra270226 star_30
|
||||
8200006 wikandana090126 star_30
|
||||
|
||||
8200008 kariasa020226 star_30
|
||||
|
||||
8200011 tandeg210226 star_30
|
||||
82100002 priska190126 star_30
|
||||
82400002 risma200226 star_30
|
||||
|
||||
|
||||
8300004 wirawan301225 star_30
|
||||
83300002 sudarsa250226 star_30
|
||||
83300003 edi020326 star_30
|
||||
83500002 rusni290126 star_30
|
||||
|
||||
|
||||
84100002 devi070226 star_30
|
||||
84100003 merta280226 star_30
|
||||
8500008 diah170226 star_10
|
||||
8700002 handayani230126 star_30
|
||||
|
1980
ppp178.rsc
Normal file
1980
ppp178.rsc
Normal file
File diff suppressed because it is too large
Load Diff
16
ppp_profile_diffs.csv
Normal file
16
ppp_profile_diffs.csv
Normal file
@@ -0,0 +1,16 @@
|
||||
Username,Profile Router 66,Profile Router 178
|
||||
1600004,star_20,EXPIRED
|
||||
1700023,star_10,EXPIRED
|
||||
1800005,EXPIRED,hemat
|
||||
221128130296,bali_10,EXPIRED
|
||||
2500011,star_20,EXPIRED
|
||||
2600001,EXPIRED,hemat
|
||||
500014,star_10,hemat
|
||||
81100008,star_30,star_50
|
||||
devaglp,star_20,star_30
|
||||
edo,free1,hemat
|
||||
jayenmecutan,free2,hemat
|
||||
ksuglp,vpn,star_10
|
||||
pkbalikspd,free1,hemat
|
||||
smctest,star_20,star_30
|
||||
sukarma,free1,hemat
|
||||
|
30
pull_backup.sh
Normal file
30
pull_backup.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
# Script to pull backup from Gitea Server
|
||||
# Run inside Alpine container
|
||||
|
||||
# Configuration
|
||||
REMOTE_USER="wartana"
|
||||
REMOTE_HOST="103.138.63.186"
|
||||
REMOTE_DIR="/home/wartana/myApp/iix/myBackup/"
|
||||
LOCAL_DIR="/data/myBackup"
|
||||
SSH_KEY="/mikrotik.key"
|
||||
|
||||
echo "[$(date)] Starting backup pull..."
|
||||
|
||||
# Ensure key has correct permissions
|
||||
chmod 600 "$SSH_KEY"
|
||||
|
||||
# Run Rsync
|
||||
# -a: archive mode
|
||||
# -v: verbose
|
||||
# -z: compress
|
||||
# --delete: mirror (delete local files if gone from remote)
|
||||
# -e: ssh with specific key and ignoring known_hosts (optional for automation)
|
||||
rsync -avz --delete -e "ssh -i $SSH_KEY -o StrictHostKeyChecking=no -p 22" \
|
||||
"$REMOTE_USER@$REMOTE_HOST:$REMOTE_DIR" "$LOCAL_DIR/"
|
||||
|
||||
echo "[$(date)] Backup pull completed."
|
||||
# Local structure will be:
|
||||
# /data/myBackup/Mikrotik/
|
||||
# /data/myBackup/Billing/
|
||||
# /data/myBackup/Server/
|
||||
1
rencana.txt
Normal file
1
rencana.txt
Normal file
@@ -0,0 +1 @@
|
||||
buat jadwal backup di mikrotik setiap jam 2 pagi, binari dan rsc file. kirim ke ftp server
|
||||
11
sync_gdrive.sh
Executable file
11
sync_gdrive.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
# Sync local mikrotik backups to Google Drive
|
||||
# Runs daily to keep the cloud copies updated
|
||||
|
||||
BACKUP_DIR="/home/wartana/myApp/iix/myBackup/Mikrotik"
|
||||
REMOTE_DIR="gdrive:myBackup/Mikrotik"
|
||||
LOG_FILE="/home/wartana/myApp/iix/gdrive_sync.log"
|
||||
|
||||
echo "[$(date)] Starting rclone sync to Google Drive..." >> $LOG_FILE
|
||||
/usr/bin/rclone sync "$BACKUP_DIR" "$REMOTE_DIR" --log-file="$LOG_FILE" --log-level INFO
|
||||
echo "[$(date)] Sync complete." >> $LOG_FILE
|
||||
89
unified_backup_sync.sh
Executable file
89
unified_backup_sync.sh
Executable file
@@ -0,0 +1,89 @@
|
||||
#!/bin/bash
|
||||
# Backup Script for MySQL Billing Database & MikroTik Google Drive Sync
|
||||
# Author: Antigravity Agent
|
||||
# Date: 2026-03-13
|
||||
|
||||
set -e
|
||||
|
||||
BACKUP_BILLING_DIR="/home/wartana/myApp/iix/myBackup/Billing"
|
||||
BACKUP_MIKROTIK_DIR="/home/wartana/myApp/iix/myBackup/Mikrotik"
|
||||
BACKUP_SERVER_DIR="/home/wartana/myApp/iix/myBackup/Server"
|
||||
DATE=$(date +%F_%H-%M-%S)
|
||||
RCLONE_REMOTE_BILLING="gdrive:myBackup/Billing"
|
||||
RCLONE_REMOTE_MIKROTIK="gdrive:myBackup/Mikrotik"
|
||||
RCLONE_REMOTE_SERVER="gdrive:myBackup/Server"
|
||||
RCLONE_CONFIG="/home/wartana/.config/rclone/rclone.conf"
|
||||
LOG_FILE="/var/log/billing_mikrotik_backup.log"
|
||||
|
||||
MYSQL_HOST="103.138.63.188"
|
||||
MYSQL_USER="chatbot"
|
||||
MYSQL_PASS="afSXzFn_tLlve(@H"
|
||||
MYSQL_DB="billinggold"
|
||||
|
||||
mkdir -p "$BACKUP_BILLING_DIR"
|
||||
mkdir -p "$BACKUP_MIKROTIK_DIR"
|
||||
mkdir -p "$BACKUP_SERVER_DIR"
|
||||
|
||||
log() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | sudo tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
log "=========================================================="
|
||||
log "Starting Database Backup & Cloud Sync process..."
|
||||
|
||||
# 1. Billing Database Backup
|
||||
log "Creating MySQL dump for $MYSQL_DB from $MYSQL_HOST..."
|
||||
DUMP_FILE="$BACKUP_BILLING_DIR/billinggold-$DATE.sql.gz"
|
||||
mysqldump -h "$MYSQL_HOST" -u "$MYSQL_USER" -p"$MYSQL_PASS" --single-transaction "$MYSQL_DB" | gzip > "$DUMP_FILE"
|
||||
log "Database dump saved to $DUMP_FILE"
|
||||
|
||||
# 2. Upload Billing to Google Drive (myBackup/Billing)
|
||||
log "Uploading Billing Backup to Google Drive (myBackup/Billing)..."
|
||||
if rclone --config "$RCLONE_CONFIG" copy "$BACKUP_BILLING_DIR" "$RCLONE_REMOTE_BILLING" --transfers=4 --checkers=8; then
|
||||
log "Upload for Billing Database successful."
|
||||
else
|
||||
log "ERROR: Upload for Billing Database failed."
|
||||
fi
|
||||
|
||||
# 3. Upload MikroTik to Google Drive (myBackup/Mikrotik)
|
||||
# Compress any new (uncompressed) .backup and .rsc files to save space
|
||||
log "Compressing new MikroTik backup files..."
|
||||
find "$BACKUP_MIKROTIK_DIR" -type f \( -name "*.backup" -o -name "*.rsc" \) ! -name "*.gz" -exec gzip -f {} \;
|
||||
log "Compression done."
|
||||
|
||||
log "Applying read permissions to MikroTik backups for upload..."
|
||||
sudo chmod 644 "$BACKUP_MIKROTIK_DIR"/*.gz 2>/dev/null || log "Warning: Could not change permissions for MikroTik backups."
|
||||
|
||||
log "Uploading MikroTik Backup to Google Drive (myBackup/Mikrotik)..."
|
||||
if rclone --config "$RCLONE_CONFIG" copy "$BACKUP_MIKROTIK_DIR" "$RCLONE_REMOTE_MIKROTIK" --transfers=4 --checkers=8; then
|
||||
log "Upload for MikroTik Backup successful."
|
||||
else
|
||||
log "ERROR: Upload for MikroTik Backup failed."
|
||||
fi
|
||||
|
||||
# 4. Upload Server Backups to Google Drive (myBackup/Server)
|
||||
if [ "$(ls -A "$BACKUP_SERVER_DIR" 2>/dev/null)" ]; then
|
||||
log "Uploading Server Backup to Google Drive (myBackup/Server)..."
|
||||
if rclone --config "$RCLONE_CONFIG" copy "$BACKUP_SERVER_DIR" "$RCLONE_REMOTE_SERVER" --transfers=4 --checkers=8; then
|
||||
log "Upload for Server Backup successful."
|
||||
else
|
||||
log "ERROR: Upload for Server Backup failed."
|
||||
fi
|
||||
else
|
||||
log "No server backups found, skipping server upload."
|
||||
fi
|
||||
|
||||
# 5. Cleanup old cloud backups (keep last 30 days)
|
||||
log "Cleaning up old cloud backups (older than 30 days)..."
|
||||
rclone --config "$RCLONE_CONFIG" delete "$RCLONE_REMOTE_BILLING" --min-age 30d || log "Warning: Cloud cleanup for Billing failed."
|
||||
rclone --config "$RCLONE_CONFIG" delete "$RCLONE_REMOTE_MIKROTIK" --min-age 30d || log "Warning: Cloud cleanup for MikroTik failed."
|
||||
rclone --config "$RCLONE_CONFIG" delete "$RCLONE_REMOTE_SERVER" --min-age 30d || log "Warning: Cloud cleanup for Server failed."
|
||||
|
||||
# 6. Cleanup old local backups (keep last 30 days)
|
||||
log "Cleaning up old local backups (older than 30 days)..."
|
||||
find "$BACKUP_BILLING_DIR" -type f -mtime +30 -delete
|
||||
find "$BACKUP_MIKROTIK_DIR" -type f -mtime +30 -delete
|
||||
find "$BACKUP_SERVER_DIR" -type f -mtime +30 -delete
|
||||
|
||||
log "All Backup processes completed."
|
||||
log "=========================================================="
|
||||
Reference in New Issue
Block a user