#!/bin/bash

BACKUPDIR=$(ls -td /var/lib/univention-appcenter/backups/appcenter-backup-minio:*/ 2>/dev/null 1| head -1)
APPDIR="/var/lib/univention-appcenter/apps/minio/"

# check if a previous backup exists and move it back into the app directory
if [ -d "$BACKUPDIR" ] && [ ! -d "$APPDIR"/data ]; then
	echo "restoring backup from a previous app"
	mkdir -p "$APPDIR"
	rsync -avP "$BACKUPDIR" "$APPDIR"
else
	echo "App is already installed or no backup present"
fi
