4 KiB
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
- Clone the repository:
git clone https://github.com/yourusername/ProxmoxBackupsServer-to-SMB.git
cd ProxmoxBackupsServer-to-SMB
- Make the script executable:
chmod +x backups2smb.sh
- Configure the script by editing the configuration section at the top of
backups2smb.sh
:
# === 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)
- Create the credentials file:
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:
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:
./backups2smb.sh
Restore from Backup
To restore from the latest backup:
./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 serverSHARE_NAME
: Name of the SMB shareMOUNT_POINT
: Local mount point for the SMB shareCREDENTIALS_FILE
: Path to the SMB credentials fileCHUNK_SIZE
: Size of backup chunks (e.g., "10G")MIN_SPACE_REQUIRED
: Minimum required space in /tmpLOG
: Path to the log fileSRC
: 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
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