diff --git a/README.md b/README.md index bdec8f6..fae41d7 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ ## Quick Start -### If the backup disk is different from the installation disk: +### Create mount point in system: Copy the UUID of your external disk: @@ -39,6 +39,10 @@ Reload system dameon: sudo systemctl daemon-reload +Mount disks: + + sudo mount -a + ### Modify custom service: @@ -78,8 +82,8 @@ Enable backup service: ### Modify script: ``` # Paths -# Default backup saved on external disk -external_disk=true +# Unmount disk after save backup (default is true) +unmount_dick=true # Disk backup mount point backup_path="/backup-disk" @@ -99,7 +103,9 @@ The default path is ExecStart=/home/backup-files.sh sudo cp backup-files.sh /home/ +Concede execute permission: + sudo chmod +x /home/backup-files.sh ### Test script commands: @@ -127,8 +133,6 @@ Start service: ## View Backup Files -### If the backup disk is different from the installation disk: - Show disks: sudo lsblk @@ -137,10 +141,6 @@ Mount the external disk. An example command contains disk /dev/sdb1 and a mount sudo mount /dev/sdb1 /backup-files -
- -### Or if the backup disk is the installation disk: - Enter the folder configured for the script backup-files.sh: cd /backup-files diff --git a/backup-files.sh b/backup-files.sh old mode 100644 new mode 100755 index 9f64375..169da0a --- a/backup-files.sh +++ b/backup-files.sh @@ -1,8 +1,8 @@ #!/bin/bash # Paths -# Default backup saved on external disk -external_disk=true +# Unmount disk after save backup +unmount_dick=true # Disk backup mount point backup_path="/backup-disk" @@ -44,19 +44,17 @@ 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 +# 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 @@ -66,10 +64,10 @@ for (( i=0; i<${#origins[@]}; i++ )); do done -if [ external_disk ]; then - # Umount disk +# Unmount disk +if [ "$unmount_dick" = true ]; then if mountpoint -q "$backup_path"; then - echo "Umounting disk..." + echo "Unmounting disk..." umount "$backup_path" fi fi