| Crates.io | db-sync |
| lib.rs | db-sync |
| version | 0.1.1 |
| created_at | 2025-10-24 15:20:36.650076+00 |
| updated_at | 2025-10-24 15:30:36.029817+00 |
| description | A secure and stable database backup synchronization system with automatic file transfer and verification |
| homepage | https://gitcode.net/dnrops/db-sync |
| repository | https://gitcode.net/dnrops/db-sync |
| max_upload_size | |
| id | 1898591 |
| size | 129,964 |
A secure and stable database backup file synchronization system that supports automatic synchronization and verification of backup files across multiple systems.
Edit server.config.json:
{
"listen_addr": "0.0.0.0:3030",
"data": [
{
"system_name": "System Name",
"system_ip": "192.168.1.100",
"backup_dir": "./backups/System Name",
"auth_token": "your-secret-token-here"
}
]
}
Edit client.config.json:
{
"data": [
{
"system_name": "System Name",
"system_ip": "192.168.1.100",
"backup_server_url": "http://server-ip:3030",
"auth_token": "your-secret-token-here",
"local_backup_dir": "./local/backups"
}
]
}
cargo build --release
Use the built-in CLI tool to generate a 512-bit authentication token for each system:
cargo run --bin gen-auth-token generate --system-ip 192.168.1.100 --system-name "HR System"
Example output:
=== DB-Sync Authentication Token Generation ===
System IP: 192.168.1.100
System Name: HR System
Token Length: 512 bits
Generated Token: 1154e194e0668a3a37ce63a28c6fe72e0200b937fb1ebb6bbf80345a8bee00c6a612fe10dac35b7781f89a13116c3cf81941c316529b0e89b2ee8ebbf3ac4846
batch_config.json:{
"secret_key": "your_custom_secret_key",
"systems": [
{
"system_ip": "192.168.1.100",
"system_name": "HR System"
},
{
"system_ip": "192.168.1.101",
"system_name": "Asset Management System"
}
]
}
cargo run --bin gen-auth-token batch --config-file batch_config.json --format json
cargo run --bin gen-auth-token validate --token "your_token_here"
cargo run --bin gen-auth-token -- --help
cargo run --bin gen-auth-token example
cargo run --bin db-sync-server
cargo run --bin db-sync-client
Run the test script:
# Windows
test_system.bat
# Linux/Mac
bash test_system.sh
GET /health
POST /api/upload
Headers:
- authorization: Bearer <token>
Query Parameters:
- system_ip: System IP
- filename: Filename
- blake3: File blake3 hash
- size: File size
Body: File binary data
POST /api/blake3
Headers:
- authorization: Bearer <token>
Query Parameters:
- system_ip: System IP
- filename: Filename
db-sync/
├── src/
│ ├── db-sync-server.rs # Server code
│ └── db-sync-client.rs # Client code
├── server.config.json # Server configuration
├── client.config.json # Client configuration
├── test_data/ # Test data
├── test_system.bat # Windows test script
├── test_system.sh # Linux/Mac test script
└── README.md # Documentation
The system uses structured logging, and the log level can be controlled via environment variables:
export RUST_LOG=info
cargo run --bin db-sync-server
Periodically check the service status:
curl http://server-ip:3030/health
Manually verify file integrity:
# Calculate blake3 checksum for local file
blake3 backup_file.sql
# Query server file blake3 checksum
curl -X POST http://server-ip:3030/api/blake3 \
-H "authorization: Bearer <token>" \
-d "system_ip=192.168.1.100&filename=backup_file.sql"
Enable verbose logging:
export RUST_LOG=debug
cargo run --bin db-sync-server
This project is licensed under the MIT License.
Package Name: db-sync
Version: 0.1.0
Minimum Rust Version: 1.70+
License: MIT
Keywords: backup, sync, database, file-transfer, security
This package is ready for publication on crates.io, providing an enterprise-grade database backup synchronization solution.
Issues and Pull Requests are welcome to improve this project.