https://github.com/rollecode/backup-to-storagebox
A bash utility for backing up your entire Linux box to Hetzner storagebox.
https://github.com/rollecode/backup-to-storagebox
Last synced: 27 days ago
JSON representation
A bash utility for backing up your entire Linux box to Hetzner storagebox.
- Host: GitHub
- URL: https://github.com/rollecode/backup-to-storagebox
- Owner: rollecode
- Created: 2025-06-13T15:25:35.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2026-03-03T12:55:18.000Z (3 months ago)
- Last Synced: 2026-05-02T13:33:28.044Z (28 days ago)
- Language: Shell
- Size: 94.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# 🚀 Backup to Storagebox
    
A simple, fast backup script for Hetzner Storageboxes.
## ⚡ Quick start
```bash
# 1. Copy and configure the environment file
cp .env.example .env
# Edit .env with your Storagebox credentials
# 2. Run backups with simple command-line syntax
./backup-to-storagebox.sh / /backups/myserver/linux
./backup-to-storagebox.sh /home/user /backups/myserver/home
./backup-to-storagebox.sh /var/www /backups/myserver/www
```
### Required environment variables
- `STORAGEBOX_USER` - Your Storagebox username (e.g., u123456)
- `STORAGEBOX_HOST` - Your Storagebox hostname (e.g., u123456.your-storagebox.de)
### Optional environment variables
- `SSH_KEY_PATH` - SSH key path (default: ~/.ssh/id_rsa)
- `SSH_PORT` - SSH port (default: 23)
- `RSYNC_MAX_SIZE` - Max file size (default: 2G)
- `RSYNC_TIMEOUT` - Connection timeout (default: 300)
- `RSYNC_BANDWIDTH_LIMIT` - Bandwidth limit (e.g., 1000 for 1MB/s)
- `BETTER_STACK_HEARTBEAT` - Better Stack heartbeat URL for monitoring
- `DRY_RUN` - Set to 'true' for dry run
## 🔧 Features
- ✅ **Simple command-line interface** - No config files needed
- ✅ **Progress display** - See individual file transfers
- ✅ **File size limiting** - Skip large files automatically
- ✅ **Configurable excludes** - Control what to exclude via EXCLUDES environment variable
- ✅ **Incremental backups** - Only transfers changed files
- ✅ **Automatic crontab backup** - Backs up all crontabs when running as root
- ✅ **Better Stack monitoring** - Optional heartbeat notifications
- ✅ **Dry run support** - Test before running
- ✅ **Hetzner Storagebox optimized** - Works perfectly with Storagebox SSH/SFTP
### Test backup (dry run)
```bash
# Edit .env to set DRY_RUN=true
./backup-to-storagebox.sh /var/www /backups/myserver/www
```
## 🔑 SSH key setup
1. Generate SSH key if you don't have one:
```bash
ssh-keygen -t rsa -b 4096
```
2. Install key on Storagebox:
```bash
cat ~/.ssh/id_rsa.pub | ssh -p 23 u123456@u123456.your-storagebox.de install-ssh-key
```
## ⏰ Cronjob
### Daily backup at 2 AM
```bash
# Edit crontab
crontab -e
# Add this line for daily backup at 2:00 AM
0 2 * * * /path/to/backup-to-storagebox.sh / /backups/myserver/linux >> /var/log/backup.log 2>&1
```
## 📊 What you'll see
```
⚡ Backup to Storagebox v2.0.0
📁 Source: /home/user/
🎯 Dest: u123456@u123456.your-storagebox.de:backups/myserver/home
📏 Largest file allowed: 2G
🔌 Testing connection...
✅ Connected
📁 Creating destination...
✅ Destination ready
🚀 Starting backup...
sending incremental file list
./
Documents/
Documents/file1.txt
1,234 100% 1.23MB/s 0:00:00 (xfr#1, to-chk=123/456)
...
🎉 Backup completed in 45s
```