Print backup logs to console so they can be previewed

This commit is contained in:
Kuba Orlik 2025-10-17 22:39:06 +02:00
parent 48b0335071
commit aab1ddf62c

View File

@ -5,28 +5,29 @@ original_dir=$(pwd)
source ./vars.sh source ./vars.sh
cd "$original_dir" cd "$original_dir"
./mount.sh & (
RESTIC_PID=$! ./mount.sh &
RESTIC_PID=$!
MOUNT_DIR="/mnt/restic" MOUNT_DIR="/mnt/restic"
# Wait until the directory exists # Wait until the directory exists
while [ ! -d "$MOUNT_DIR" ]; do while [ ! -d "$MOUNT_DIR" ]; do
echo "Waiting for directory to be created..." echo "Waiting for directory to be created..."
sleep 1 sleep 1
done done
# Wait until the directory is not empty # Wait until the directory is not empty
while [ ! "$(ls -A "$MOUNT_DIR")" ]; do while [ ! "$(ls -A "$MOUNT_DIR")" ]; do
echo "Waiting for directory to have content..." echo "Waiting for directory to have content..."
sleep 1 sleep 1
done done
# Space-separated list of absolute paths # Space-separated list of absolute paths
BACKUP_DIR="$MOUNT_DIR/snapshots/latest" BACKUP_DIR="$MOUNT_DIR/snapshots/latest"
# Iterate over each path in the array # Iterate over each path in the array
while IFS= read -r ORIGINAL_PATH; do while IFS= read -r ORIGINAL_PATH; do
# Skip empty paths # Skip empty paths
[[ -z "$ORIGINAL_PATH" ]] && continue [[ -z "$ORIGINAL_PATH" ]] && continue
@ -47,9 +48,10 @@ while IFS= read -r ORIGINAL_PATH; do
# Use rsync to copy files, preserving permissions, ownership, and timestamps # Use rsync to copy files, preserving permissions, ownership, and timestamps
rsync --archive --acls --xattrs --compress --verbose --human-readable --partial --progress "$BACKUP_PATH/" "$ORIGINAL_PATH/" rsync --archive --acls --xattrs --compress --verbose --human-readable --partial --progress "$BACKUP_PATH/" "$ORIGINAL_PATH/"
done </backup-dirs done </backup-dirs
kill -SIGINT $RESTIC_PID kill -SIGINT $RESTIC_PID
umount /mnt/restic umount /mnt/restic
echo "DONE" echo "DONE"
) >"/var/log/backup-restore-$(date +%s).log"