add check disk code

This commit is contained in:
facundo.prog 2024-04-04 12:43:23 -03:00
parent c41d3b8fd1
commit 24f1ae5974

View File

@ -2,16 +2,16 @@
# Paths # Paths
# Unmount disk after save backup # Unmount disk after save backup
unmount_dick=true unmount_disk=true
# Disk backup mount point # Disk backup mount point
backup_path="/backup-disk" backup_path="/backup-disk"
# Origins files array # Origins files array
origins=("/home/user1/files" "/home/user2/files/documents") origins=("/home/facu/Documents/backup_folder")
# Destination backups # Destination backups
destinations=("$backup_path/backup-user1" "$backup_path/backup-user2") destinations=("$backup_path/facu")
# Function to perform backup for each origin-destination pair # Function to perform backup for each origin-destination pair
perform_backup() { perform_backup() {
@ -51,10 +51,16 @@ if [ ! -d "$backup_path" ]; then
echo "Mount point disk created" echo "Mount point disk created"
fi fi
# Mount disk
mount "$backup_path"
echo "Mounting disk..."
# The disk not mount # The disk not mount
if ! mountpoint -q "$backup_path"; then if ! mountpoint -q "$backup_path"; then
echo "Mounting disk..." echo "Error occurred when mounting disk"
mount "$backup_path" exit 1
fi fi
@ -65,7 +71,7 @@ done
# Unmount disk # Unmount disk
if [ "$unmount_dick" = true ]; then if [ "$unmount_disk" = true ]; then
if mountpoint -q "$backup_path"; then if mountpoint -q "$backup_path"; then
echo "Unmounting disk..." echo "Unmounting disk..."
umount "$backup_path" umount "$backup_path"