Automated backup script for Lubelogger, a self-hosted vehicle maintenance tracker. Supports notifications via Uptime Kuma and Gotify, with automatic cleanup of old backups and logs. Includes detailed logging, API integration, and cron-friendly setup.
| LICENSE | ||
| lubelogger_backup.sh | ||
| README.md | ||
📦 Lubelogger Backup Script
This script automates the backup process for Lubelogger — a self-hosted, open-source vehicle maintenance records and fuel mileage tracker.
✅ What It Does
- Creates a backup of your Lubelogger database.
- Stores backups in a local directory.
- Notifies external systems (like Uptime Kuma and Gotify) of backup status.
- Cleans up backups and logs older than a specified retention period.
⚙️ Features
- Automated Backup via the Lubelogger API
- Success/Failure Notifications through Uptime Kuma and Gotify
- Detailed Logging with timestamps
- Retention Policy for auto-cleanup of old files
📋 Requirements
- Lubelogger (accessible API endpoint for backups)
- Curl (for HTTP requests)
- Bash (Linux or Unix-based system)
- (Optional) Uptime Kuma for monitoring
- (Optional) Gotify for alerting
🚀 Setup
1. Clone the Repository
git clone https://git.nickhepler.cloud/nick/lubelogger-backup.git
cd lubelogger-backup-script
2. Configure Environment Variables
Create a .env file:
USERNAME=rootUser
PASSWORD=rootPassword
BASE_URL=https://lubelogger.mydomain.com
BACKUP_DIR=$HOME/lubelogger_backups
RETENTION_DAYS=7
BACKUP_TAG=lubelogger-db1
# Uptime Kuma (optional)
UPTIME_KUMA_URL=https://uptime-kuma.example.com
UPTIME_KUMA_API_KEY=your-uptime-kuma-api-key
# Gotify (optional)
GOTIFY_PUSH_URL=https://push.example.de
GOTIFY_PUSH_KEY=your-app-token
Make sure your Lubelogger API credentials and URLs are correct.
Optional services like Uptime Kuma and Gotify will only be used if their variables are set.
3. Make the Script Executable
chmod +x lubelogger_backup.sh
4. Run the Backup
./lubelogger_backup.sh
5. Automate via Cron (Optional)
To schedule daily backups at 2 AM:
0 2 * * * /path/to/lubelogger_backup.sh
🔍 How It Works
- Triggers a backup via Lubelogger’s
/api/makebackup - Downloads the backup
.zipfrom the returned URL - Sends check-in to Uptime Kuma (if configured)
- Sends error notification via Gotify (if any failures)
- Generates a timestamped log file
- Deletes backups and logs older than
RETENTION_DAYS
🖥️ Example Output
[$(date)] 🔄 Starting Lubelogger backup job
[$(date)] ✅ Uptime Kuma check-in sent.
[$(date)] ⬇️ Downloading backup from https://lubelogger.mydomain.com/api/backup/download/abc123
[$(date)] ✅ Backup saved to /path/to/backup/backup_2025-04-25_14-30-00.zip
[$(date)] 🧹 Cleaning up old backups/logs older than 7 days
[$(date)] ✅ Backup job finished
🧰 Troubleshooting
Uptime Kuma
- Confirm
UPTIME_KUMA_URLandAPI_KEYare correct - Ensure check-in monitoring is configured
Gotify
- Validate push token and URL
- Confirm your Gotify server is reachable and running
Permissions
- Ensure
lubelogger_backup.shis executable - Verify
BACKUP_DIRexists and is writable
📄 License
Licensed under the GNU General Public License v3.0.
See the LICENSE file for full details.
❤️ About LubeLogger
LubeLogger is an open-source web-based vehicle maintenance and fuel mileage tracker. Learn more or contribute to the main project here: