mirror of
https://github.com/Facundo-prog/automatic_backup_script.git
synced 2025-07-06 19:12:28 +00:00
updated
This commit is contained in:
parent
02a01b0ccb
commit
d3b9aa93fe
18
README.md
18
README.md
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
### If the backup disk is different from the installation disk:
|
### Create mount point in system:
|
||||||
|
|
||||||
Copy the UUID of your external disk:
|
Copy the UUID of your external disk:
|
||||||
|
|
||||||
@ -39,6 +39,10 @@ Reload system dameon:
|
|||||||
|
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
|
|
||||||
|
Mount disks:
|
||||||
|
|
||||||
|
sudo mount -a
|
||||||
|
|
||||||
|
|
||||||
### Modify custom service:
|
### Modify custom service:
|
||||||
|
|
||||||
@ -78,8 +82,8 @@ Enable backup service:
|
|||||||
### Modify script:
|
### Modify script:
|
||||||
```
|
```
|
||||||
# Paths
|
# Paths
|
||||||
# Default backup saved on external disk
|
# Unmount disk after save backup (default is true)
|
||||||
external_disk=true
|
unmount_dick=true
|
||||||
|
|
||||||
# Disk backup mount point
|
# Disk backup mount point
|
||||||
backup_path="/backup-disk"
|
backup_path="/backup-disk"
|
||||||
@ -99,7 +103,9 @@ The default path is ExecStart=/home/backup-files.sh
|
|||||||
|
|
||||||
sudo cp backup-files.sh /home/
|
sudo cp backup-files.sh /home/
|
||||||
|
|
||||||
|
Concede execute permission:
|
||||||
|
|
||||||
|
sudo chmod +x /home/backup-files.sh
|
||||||
|
|
||||||
### Test script commands:
|
### Test script commands:
|
||||||
|
|
||||||
@ -127,8 +133,6 @@ Start service:
|
|||||||
|
|
||||||
## View Backup Files
|
## View Backup Files
|
||||||
|
|
||||||
### If the backup disk is different from the installation disk:
|
|
||||||
|
|
||||||
Show disks:
|
Show disks:
|
||||||
|
|
||||||
sudo lsblk
|
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
|
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:
|
Enter the folder configured for the script backup-files.sh:
|
||||||
|
|
||||||
cd /backup-files
|
cd /backup-files
|
||||||
|
32
backup-files.sh
Normal file → Executable file
32
backup-files.sh
Normal file → Executable file
@ -1,8 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Paths
|
# Paths
|
||||||
# Default backup saved on external disk
|
# Unmount disk after save backup
|
||||||
external_disk=true
|
unmount_dick=true
|
||||||
|
|
||||||
# Disk backup mount point
|
# Disk backup mount point
|
||||||
backup_path="/backup-disk"
|
backup_path="/backup-disk"
|
||||||
@ -44,19 +44,17 @@ perform_backup() {
|
|||||||
return 0
|
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
|
# The mount point disk not exists
|
||||||
if ! mountpoint -q "$backup_path"; then
|
if [ ! -d "$backup_path" ]; then
|
||||||
echo "Mounting disk..."
|
mkdir -p "$backup_path"
|
||||||
mount "$backup_path"
|
echo "Mount point disk created"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# The disk not mount
|
||||||
|
if ! mountpoint -q "$backup_path"; then
|
||||||
|
echo "Mounting disk..."
|
||||||
|
mount "$backup_path"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
@ -66,10 +64,10 @@ for (( i=0; i<${#origins[@]}; i++ )); do
|
|||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
if [ external_disk ]; then
|
# Unmount disk
|
||||||
# Umount disk
|
if [ "$unmount_dick" = true ]; then
|
||||||
if mountpoint -q "$backup_path"; then
|
if mountpoint -q "$backup_path"; then
|
||||||
echo "Umounting disk..."
|
echo "Unmounting disk..."
|
||||||
umount "$backup_path"
|
umount "$backup_path"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user