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
|
||||
|
||||
### 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
|
||||
|
24
backup-files.sh
Normal file → Executable file
24
backup-files.sh
Normal file → Executable 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
|
||||
|
||||
# The mount point disk not exists
|
||||
if [ ! -d "$backup_path" ]; then
|
||||
mkdir -p "$backup_path"
|
||||
echo "Mount point disk created"
|
||||
fi
|
||||
fi
|
||||
|
||||
# The disk not mount
|
||||
if ! mountpoint -q "$backup_path"; then
|
||||
# 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
|
||||
|
||||
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user