This commit is contained in:
facundo.prog 2024-04-04 00:31:05 -03:00
parent 02a01b0ccb
commit d3b9aa93fe
2 changed files with 24 additions and 26 deletions

View File

@ -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
</br>
### Or if the backup disk is the installation disk:
Enter the folder configured for the script backup-files.sh:
cd /backup-files

32
backup-files.sh Normal file → Executable file
View File

@ -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