140 lines
No EOL
4 KiB
Markdown
140 lines
No EOL
4 KiB
Markdown
# Proxmox Backup Server to SMB Backup Script
|
|
|
|
A robust and efficient backup solution for Proxmox Backup Server (PBS) that securely transfers backups to an SMB share. This script provides incremental backups, efficient space management, and detailed logging.
|
|
|
|
## Features
|
|
|
|
- 🔄 Incremental backups with file change detection
|
|
- 📦 Chunked backup creation for large datasets
|
|
- 💾 Efficient space management with configurable chunk sizes
|
|
- 🔍 Detailed logging and progress tracking
|
|
- 🔒 Secure SMB authentication
|
|
- 🧹 Automatic cleanup of old backups
|
|
- 🔁 Restore functionality
|
|
- 📊 SQLite database for tracking file changes
|
|
- ⚡ Optimized performance with batch processing
|
|
|
|
## Prerequisites
|
|
|
|
- Linux-based system (tested on Proxmox Backup Server)
|
|
- Required packages:
|
|
- `sqlite3`
|
|
- `7zip`
|
|
- `rsync`
|
|
- `cifs-utils`
|
|
- `pv` (optional, for progress bars)
|
|
|
|
## Installation
|
|
|
|
1. Clone the repository:
|
|
```bash
|
|
git clone https://github.com/yourusername/ProxmoxBackupsServer-to-SMB.git
|
|
cd ProxmoxBackupsServer-to-SMB
|
|
```
|
|
|
|
2. Make the script executable:
|
|
```bash
|
|
chmod +x backups2smb.sh
|
|
```
|
|
|
|
3. Configure the script by editing the configuration section at the top of `backups2smb.sh`:
|
|
```bash
|
|
# === Config ===
|
|
SERVER_IP="192.168.2.194" # Your SMB server IP
|
|
SHARE_NAME="PBS-back" # SMB share name
|
|
MOUNT_POINT="/mnt/smb-backup" # Local mount point
|
|
CREDENTIALS_FILE="/root/.smb-pbs-cred" # SMB credentials file
|
|
CHUNK_SIZE="10G" # Size of backup chunks
|
|
MIN_SPACE_REQUIRED="5G" # Minimum required space in /tmp
|
|
SRC="/mypool /etc" # Directories to backup (space-separated)
|
|
```
|
|
|
|
4. Create the credentials file:
|
|
```bash
|
|
echo "username=your_username" > /root/.smb-pbs-cred
|
|
echo "password=your_password" >> /root/.smb-pbs-cred
|
|
chmod 600 /root/.smb-pbs-cred
|
|
```
|
|
|
|
## Backup Targets Configuration
|
|
|
|
The script allows you to specify multiple directories to backup. In the configuration section, the `SRC` variable defines which directories will be included in the backup:
|
|
|
|
```bash
|
|
SRC="/mypool /etc" # Example configuration
|
|
```
|
|
|
|
You can customize this to include any directories you want to backup. For example:
|
|
- For a Proxmox server: `SRC="/etc/pve /var/lib/vz"`
|
|
- For a web server: `SRC="/var/www /etc/nginx /etc/apache2"`
|
|
- For a database server: `SRC="/var/lib/postgresql /etc/postgresql"`
|
|
|
|
Multiple directories should be space-separated. The script will automatically handle the backup of all specified directories.
|
|
|
|
## Usage
|
|
|
|
### Regular Backup
|
|
|
|
Run the script without any arguments to perform a regular backup:
|
|
|
|
```bash
|
|
./backups2smb.sh
|
|
```
|
|
|
|
### Restore from Backup
|
|
|
|
To restore from the latest backup:
|
|
|
|
```bash
|
|
./backups2smb.sh -u
|
|
```
|
|
|
|
## Configuration Options
|
|
|
|
The script can be customized by modifying the following variables in the configuration section:
|
|
|
|
- `SERVER_IP`: IP address of your SMB server
|
|
- `SHARE_NAME`: Name of the SMB share
|
|
- `MOUNT_POINT`: Local mount point for the SMB share
|
|
- `CREDENTIALS_FILE`: Path to the SMB credentials file
|
|
- `CHUNK_SIZE`: Size of backup chunks (e.g., "10G")
|
|
- `MIN_SPACE_REQUIRED`: Minimum required space in /tmp
|
|
- `LOG`: Path to the log file
|
|
- `SRC`: Directories to backup (space-separated)
|
|
|
|
## Logging
|
|
|
|
The script maintains detailed logs at `/var/log/pbs-smb-backup.log`. Logs older than 7 days are automatically cleaned up.
|
|
|
|
## Error Handling
|
|
|
|
The script includes comprehensive error handling for:
|
|
- Network connectivity issues
|
|
- SMB mount failures
|
|
- Space constraints
|
|
- Process cleanup
|
|
- Database operations
|
|
|
|
## Contributing
|
|
|
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
|
|
## Support and Community
|
|
|
|
Join our Discord community for support, discussions, and updates:
|
|
[Pandem Discord Server](https://discord.gg/rcqUj2mFBm)
|
|
|
|
## Contact
|
|
|
|
For support or questions, please contact:
|
|
- Email: gabriel@pandem.fr
|
|
- Discord: Join our server at https://discord.gg/rcqUj2mFBm
|
|
|
|
## License
|
|
|
|
This project is licensed under the MIT License - see the LICENSE file for details.
|
|
|
|
## Acknowledgments
|
|
|
|
- Thanks to the Proxmox team for their excellent backup server
|
|
- Inspired by various backup solutions in the Linux community |