ระบบสำรองข้อมูลฐานข้อมูล SQL อัตโนมัติพร้อมตัวเลือกการจัดเก็บหลายรูปแบบ
- ✅ รองรับหลายฐานข้อมูล (MySQL, PostgreSQL, MSSQL)
- ✅ สำรองข้อมูลอัตโนมัติตามตารางเวลา (Cron Schedule)
- ✅ บันทึกไฟล์สำรองข้อมูลในเครื่อง (Local Storage)
- ✅ อัปโหลดไปยัง Discord Webhook
- ✅ จัดการไฟล์สำรองข้อมูลเก่า (Retention Management)
- ✅ ระบบ Logging
- ✅ รองรับ Authentication Plugins หลายแบบ
- Node.js 16+
- MySQL/MariaDB, PostgreSQL, หรือ SQL Server
- npm หรือ yarn
- Clone repository
git clone https://github.com/Nutexe999/backup_database_mysql.git
cd backup_database_mysql- ติดตั้ง dependencies
npm install- คัดลอกไฟล์ config
copy config.example.json config.json- แก้ไขการตั้งค่าใน
config.json
แก้ไขไฟล์ config.json:
{
"database": {
"type": "mysql",
"host": "localhost",
"port": 3306,
"user": "root",
"password": "your_password",
"database": "your_database",
"options": {}
},
"backup": {
"outputDir": "./backups",
"retentionDays": 7,
"schedule": "*/30 * * * *",
"format": "sql"
},
"storage": {
"local": {
"enabled": true
},
"discord": {
"enabled": true,
"webhookUrl": "YOUR_DISCORD_WEBHOOK_URL",
"maxFileSize": 25000000
}
},
"logging": {
"enabled": true,
"level": "info",
"file": "./logs/backup.log"
}
}mysql- MySQL/MariaDBpostgresqlหรือpostgres- PostgreSQLmssqlหรือsqlserver- Microsoft SQL Server
ใช้รูปแบบ Cron Schedule:
*/30 * * * *- ทุก 30 นาที0 2 * * *- ทุกวันเวลา 02:000 */6 * * *- ทุก 6 ชั่วโมง0 0 * * 0- ทุกวันอาทิตย์เวลา 00:00
npm startหรือใช้ไฟล์ batch (Windows):
Run.batลบหรือ comment ส่วน schedule ใน config.json แล้วรัน:
npm startหากพบปัญหา authentication plugin (เช่น auth_gssapi_client):
ALTER USER 'your_user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'your_password';
FLUSH PRIVILEGES;ALTER USER 'your_user'@'%' IDENTIFIED WITH mysql_native_password BY 'your_password';
FLUSH PRIVILEGES;backup_database_mysql/
├── index.js # Main entry point
├── config.json # Configuration file (use config.example.json as template)
├── config.example.json # Configuration template
├── package.json # Dependencies
├── modules/
│ ├── backup.js # Database backup logic
│ ├── discord.js # Discord webhook uploader
│ └── logger.js # Logging system
├── backups/ # Backup files storage
└── logs/ # Log files
mysql2- MySQL/MariaDB clientpg- PostgreSQL clientmssql- SQL Server clientnode-cron- Task schedulingaxios- HTTP client for Discordfs-extra- Enhanced file system operationsform-data- Form data handling
MIT License
Nut.exe
- Discord: https://discord.gg/JRaWs4QdW4
- GitHub: https://github.com/Nutexe999
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.
โปรดตรวจสอบการตั้งค่าก่อนใช้งานจริง และเก็บรักษา credentials อย่างปลอดภัย อย่า commit config.json ที่มีข้อมูลจริงขึ้น GitHub