Print backup logs to console so they can be previewed
This commit is contained in:
parent
48b0335071
commit
aab1ddf62c
@ -5,51 +5,53 @@ original_dir=$(pwd)
|
||||
source ./vars.sh
|
||||
cd "$original_dir"
|
||||
|
||||
./mount.sh &
|
||||
RESTIC_PID=$!
|
||||
(
|
||||
./mount.sh &
|
||||
RESTIC_PID=$!
|
||||
|
||||
MOUNT_DIR="/mnt/restic"
|
||||
MOUNT_DIR="/mnt/restic"
|
||||
|
||||
# Wait until the directory exists
|
||||
while [ ! -d "$MOUNT_DIR" ]; do
|
||||
echo "Waiting for directory to be created..."
|
||||
sleep 1
|
||||
done
|
||||
# Wait until the directory exists
|
||||
while [ ! -d "$MOUNT_DIR" ]; do
|
||||
echo "Waiting for directory to be created..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Wait until the directory is not empty
|
||||
while [ ! "$(ls -A "$MOUNT_DIR")" ]; do
|
||||
echo "Waiting for directory to have content..."
|
||||
sleep 1
|
||||
done
|
||||
# Wait until the directory is not empty
|
||||
while [ ! "$(ls -A "$MOUNT_DIR")" ]; do
|
||||
echo "Waiting for directory to have content..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Space-separated list of absolute paths
|
||||
BACKUP_DIR="$MOUNT_DIR/snapshots/latest"
|
||||
# Space-separated list of absolute paths
|
||||
BACKUP_DIR="$MOUNT_DIR/snapshots/latest"
|
||||
|
||||
# Iterate over each path in the array
|
||||
while IFS= read -r ORIGINAL_PATH; do
|
||||
# Skip empty paths
|
||||
[[ -z "$ORIGINAL_PATH" ]] && continue
|
||||
# Iterate over each path in the array
|
||||
while IFS= read -r ORIGINAL_PATH; do
|
||||
# Skip empty paths
|
||||
[[ -z "$ORIGINAL_PATH" ]] && continue
|
||||
|
||||
# Construct the corresponding backup path
|
||||
BACKUP_PATH="$BACKUP_DIR$ORIGINAL_PATH"
|
||||
# Construct the corresponding backup path
|
||||
BACKUP_PATH="$BACKUP_DIR$ORIGINAL_PATH"
|
||||
|
||||
# Check if the backup directory exists
|
||||
if [[ ! -d "$BACKUP_PATH" ]]; then
|
||||
echo "Backup directory not found: $BACKUP_PATH"
|
||||
continue
|
||||
fi
|
||||
# Check if the backup directory exists
|
||||
if [[ ! -d "$BACKUP_PATH" ]]; then
|
||||
echo "Backup directory not found: $BACKUP_PATH"
|
||||
continue
|
||||
fi
|
||||
|
||||
# Ensure the original directory exists, create it if not
|
||||
if [[ ! -d "$ORIGINAL_PATH" ]]; then
|
||||
echo "Creating original directory: $ORIGINAL_PATH"
|
||||
mkdir -p "$ORIGINAL_PATH"
|
||||
fi
|
||||
# Ensure the original directory exists, create it if not
|
||||
if [[ ! -d "$ORIGINAL_PATH" ]]; then
|
||||
echo "Creating original directory: $ORIGINAL_PATH"
|
||||
mkdir -p "$ORIGINAL_PATH"
|
||||
fi
|
||||
|
||||
# Use rsync to copy files, preserving permissions, ownership, and timestamps
|
||||
rsync --archive --acls --xattrs --compress --verbose --human-readable --partial --progress "$BACKUP_PATH/" "$ORIGINAL_PATH/"
|
||||
done </backup-dirs
|
||||
# Use rsync to copy files, preserving permissions, ownership, and timestamps
|
||||
rsync --archive --acls --xattrs --compress --verbose --human-readable --partial --progress "$BACKUP_PATH/" "$ORIGINAL_PATH/"
|
||||
done </backup-dirs
|
||||
|
||||
kill -SIGINT $RESTIC_PID
|
||||
umount /mnt/restic
|
||||
kill -SIGINT $RESTIC_PID
|
||||
umount /mnt/restic
|
||||
|
||||
echo "DONE"
|
||||
echo "DONE"
|
||||
) >"/var/log/backup-restore-$(date +%s).log"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user