Homey Self-Hosted Server on Linux | Megathread

The description states that the data is safe because it’s not in the container. That’s incorrect. So, how do I create a backup? The specified folder is empty :man_shrugging:

No data separately in ~/.homey-shs (or somewhere else if you configured that?).

(I have created a cron job that do a nightly backup in a script performing docker pause, backup of data and then unpause on mine).

The job is executed by Linux itself? And the entire container is backed up? A short guide would be great.

I am somewhat familiar with linux, but not docker so I asked chatgp for advice.

In the YML I am storing the data in a different place than default:
volumes:
- /srv/homey/data:/homey/user

Script:

bjornb@NUC:~$ cat /usr/local/bin/homey-backup.sh
#!/bin/bash
set -e

BACKUP_DIR="/var/backups/homey"
DATA_DIR="/srv/homey/data"
COMPOSE_FILE="/srv/homey/homey-shs.yml"
TIMESTAMP=$(date +"%Y-%m-%d_%H-%M")
BACKUP_FILE="$BACKUP_DIR/homey-backup-$TIMESTAMP.tar.gz"
KEEP_DAYS=14

echo "[INFO] Starting Homey backup: $TIMESTAMP"

# Stop Homey cleanly
#docker compose -f "$COMPOSE_FILE" down
docker pause homey-shs

# Create backup
tar -czf "$BACKUP_FILE" -C /srv/homey data

# Restart Homey
#docker compose -f "$COMPOSE_FILE" up -d
docker unpause homey-shs

# Remove backups older than KEEP_DAYS
find "$BACKUP_DIR" -type f -name "homey-*.tar.gz" -mtime +$KEEP_DAYS -delete

echo "[INFO] Backup completed successfully"
bjornb@NUC:~$

(I have not tried to do a an actual restore yet, but the tar.gz file does contain a lot of data).

The script is running nightly as a cron job.

2 Likes

thank you :ok_hand: