diff --git a/README.md b/README.md index c67b24f..bdec8f6 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,9 @@ Edit the mount points file: Replace the disk `UUID` and `mount point` (default is "/backup-disk") with your configuration: + +View fstab file for more information. + ``` # @@ -32,6 +35,10 @@ UUID=645648-kadfvadfb86teyn1sd3 /boot/efi vfat umask=0077 0 UUID= / ext4 defaults 0 0 ``` +Reload system dameon: + + sudo systemctl daemon-reload + ### Modify custom service: @@ -62,10 +69,6 @@ Copy script: sudo cp backup-files.service /etc/systemd/system/ -Reload system dameon: - - sudo systemctl dameon-reload - Enable backup service: sudo systemctl enable backup-files.service @@ -122,7 +125,7 @@ Start service:
-## View backup files +## View Backup Files ### If the backup disk is different from the installation disk: @@ -130,7 +133,7 @@ Show disks: sudo lsblk -Mount external disk. Command example contain disñ /dev/sdb1 and a mount point is "/backup-files": +Mount the external disk. An example command contains disk /dev/sdb1 and a mount point is "/backup-files": sudo mount /dev/sdb1 /backup-files @@ -138,6 +141,6 @@ Mount external disk. Command example contain disñ /dev/sdb1 and a mount point i ### Or if the backup disk is the installation disk: -Enter in folder cofigured of script backup-files.sh: +Enter the folder configured for the script backup-files.sh: cd /backup-files diff --git a/backup-files.sh b/backup-files.sh index 55cdb7a..9f64375 100644 --- a/backup-files.sh +++ b/backup-files.sh @@ -24,22 +24,6 @@ perform_backup() { return 1 fi - if [ external_disk ]; then - - # The mount point disk not exists - if [ ! -d "$backup_path" ]; then - mkdir -p "$backup_path" - echo "Mount point disk created" - fi - - # The disk not mount - if ! mountpoint -q "$backup_path"; then - echo "Mounting disk..." - mount "$backup_path" - fi - fi - - # The destination folder not exists if [ ! -d "$destination" ]; then echo "Folder $destination created" @@ -60,6 +44,22 @@ perform_backup() { return 0 } +# Check if the mount point exists and disk is mounted +if [ external_disk ]; then + # The mount point disk not exists + if [ ! -d "$backup_path" ]; then + mkdir -p "$backup_path" + echo "Mount point disk created" + fi + + # The disk not mount + if ! mountpoint -q "$backup_path"; then + echo "Mounting disk..." + mount "$backup_path" + fi +fi + + # Iterate over origin-destination pairs and perform backup for (( i=0; i<${#origins[@]}; i++ )); do perform_backup "${origins[i]}" "${destinations[i]}" diff --git a/fstab b/fstab index 5d29774..3160d04 100644 --- a/fstab +++ b/fstab @@ -10,7 +10,7 @@ # # Others discks -UUID= /boot/efi vfat umask=0077 0 1 +UUID=645648-kadfvadfb86teyn1sd3 /boot/efi vfat umask=0077 0 1 # backup external disk -UUID= /backup-disk ext4 defaults 0 0 +UUID=45afds53g /backup-disk ext4 defaults 0 0