Skip to content

Commit f11bc1d

Browse files
committed
v1.0.0.22 2025/04/29 add installer app
1 parent dcc5cf0 commit f11bc1d

20 files changed

+1296
-925
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
ignored/
2+
edit_sh_scripts.sh

README.md

+28-54
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Linux Backup Script
22

33
## Description
4-
A Linux backup script with options for mirrored (sync) and incremental backups.
4+
A Linux backup script with options for mirrored and incremental backups and remote bidirectional ssh support.
55

66
## Requirements
77
- **Operating System**: Linux.
@@ -10,8 +10,9 @@ A Linux backup script with options for mirrored (sync) and incremental backups.
1010
---
1111

1212
## Features
13+
- Remote ssh backup support.
1314
- Detailed logs in the destination directory.
14-
- Easy replication of backups to multiple disk drives.
15+
- Easy replication of backups to multiple disk drives or server location.
1516
- Crontab scheduling capability.
1617
- Fast incremental backups.
1718
- configuration file separate from the main script.
@@ -24,58 +25,36 @@ A Linux backup script with options for mirrored (sync) and incremental backups.
2425

2526
2. It's recommended to encrypt the destination drive with LUKS and set a secret password, noting it down in your password manager or on paper.
2627

27-
3. Choose which set of scripts you want to use (items 4, 5, or 6), as using them together may cause increased disk space usage.
28+
3. Set run permission to the 'install.sh', 'remove.sh', and 'ssh_auto_config.sh' scripts
2829

29-
4. For **mirror backups**, copy (`make_rsync_backup.sh`, `restore_rsync_backup.sh`, `backup_path.txt`, and `Sounds` folder), to the destination drive.
30+
4. Double-click on 'install.sh' to install app
3031

31-
5. For **incremental backups with rsync**, copy (`make_rsync_inc_backup.sh`, `inc_backup_path.txt`, and `Sounds` folder) to the destination drive.
32+
5. Open 'ssh_auto_config.sh' and set 'SSH_USER_SERVER' to your username@servername
3233

33-
6. For **incremental backups with tar**, copy (`make_tar_inc_backup.sh`, `restore_tar_inc_backup.sh`, `inc_backup_path.txt`, and `Sounds` folder) to the destination drive.
34+
6. Double-click on 'ssh_auto_config.sh' for auto config and send ssh public key to the server
3435

35-
7. Configure the source and destination directories for backups in the configuration files (`backup_path.txt` or `inc_backup_path.txt`), which will be created automatically.
36+
7. Set the source and destination directories for backups in the configuration files (`backup.conf`), which will be created automatically.
3637

37-
The first backup will be full (time-consuming), but subsequent backups will copy only modified files since the last backup, making them much faster.
38+
8. The first backup will be full (time-consuming), but subsequent backups will copy only modified files since the last backup, making them much faster.
3839

3940
---
4041

4142
## Configuration
4243

43-
### Mirror Backup
44+
### Make Backup
45+
- **BACKUP_TYPE**: Backup type selection
46+
- **DAY_LIMIT**: Number of days to keep backups (valid for rsync)
4447
- **FROM_PATH**: Source directory path for backup
4548
- **TO_PATH**: Destination directory path
4649

47-
Example (`backup_path.txt`):
50+
Example (`backup.conf`):
4851
```bash
4952

50-
#-------------------------------------------------------------------------------
51-
# Mirror Backup
52-
#-------------------------------------------------------------------------------
53+
BACKUP_TYPE=1 # Rsync Mirror Backup (with ssh support)
54+
#BACKUP_TYPE=2 # Rsync Incremental Backup
55+
#BACKUP_TYPE=3 # Tar Incremental Backup
5356

54-
FROM_PATH+=("/home/$USER/.config/gqrx")
55-
FROM_PATH+=("/media/$USER/KINGSTON_1TB/Docs/Links")
56-
FROM_PATH+=("/media/$USER/KINGSTON_1TB/Installed/EAGLE-6.3.0")
57-
FROM_PATH+=("/media/$USER/KINGSTON_1TB/Docs/Develop/Projects/My_GitHub")
58-
FROM_PATH+=("/media/$USER/KINGSTON_1TB/Docs/KeePassXC")
59-
60-
# Disk Unit 1
61-
TO_PATH+=("/media/$USER/FlashDisk1/SyncBackup")
62-
63-
# Disk Unit 2 (Replicated content)
64-
TO_PATH+=("/media/$USER/FlashDisk2/SyncBackup")
65-
66-
```
67-
68-
### Incremental Backup
69-
- **FROM_PATH**: Source directory path for backup
70-
- **TO_PATH**: Destination directory path
71-
- **DAY_LIMIT**: Number of days to keep backups (valid for rsync)
72-
73-
Example (`inc_backup_path.txt`):
74-
```bash
75-
76-
#-------------------------------------------------------------------------------
77-
# Incremental Backup
78-
#-------------------------------------------------------------------------------
57+
DAY_LIMIT=7 # backup history changes (7 days)
7958

8059
FROM_PATH+=("/home/$USER/.config/gqrx")
8160
FROM_PATH+=("/media/$USER/KINGSTON_1TB/Docs/Links")
@@ -86,10 +65,8 @@ FROM_PATH+=("/media/$USER/KINGSTON_1TB/Docs/KeePassXC")
8665
# Disk Unit 1
8766
TO_PATH+=("/media/$USER/FlashDisk1/IncBackup")
8867

89-
# Disk Unit 2 (Replicated content)
90-
TO_PATH+=("/media/$USER/FlashDisk2/IncBackup")
91-
92-
DAY_LIMIT=30 # Backup History = 30 days
68+
# Disk Unit 2 (Replicated content to remote server)
69+
TO_PATH+=("user@remote-server:/media/$USER/SSD_2TB/Backups")
9370

9471
```
9572

@@ -98,25 +75,21 @@ DAY_LIMIT=30 # Backup History = 30 days
9875
## Usage
9976

10077
```bash
101-
# Perform incremental backup with rsync
102-
./make_rsync_inc_backup.sh
10378

104-
# Perform mirrored backup with rsync
105-
./make_rsync_backup.sh
79+
# For backup directories:
80+
# Type 'backup' in the terminal window in the same directory where the backup.conf file is located
81+
backup
10682

107-
# Restore mirrored backup with rsync
108-
./restore_rsync_backup.sh
83+
# For restore directories:
84+
# Type 'restore' in the terminal window in the same directory where the backup.conf file is located
85+
restore
10986

110-
# Perform incremental backup with tar
111-
./make_tar_inc_backup.sh
112-
113-
# Restore incremental backup with tar
114-
./restore_tar_inc_backup.sh
11587
```
11688

11789
---
11890

11991
## Limitations
92+
- Does not copy files directly, only folders containing the files.
12093
- No built-in assistant for restoring incremental rsync backups.
12194
- Invalid file names may cause backup errors.
12295
- Backups cannot be made from Linux system files to a Windows partition (NTFS, EXFAT, FAT32, or FAT). Use Linux file systems like ext4 or btrfs instead. However, NTFS can still be used for common file copies with mirror backups.
@@ -144,7 +117,8 @@ DAY_LIMIT=30 # Backup History = 30 days
144117
| 1.0.0.17 | 2025/01/27 | Changed scripts to enable automatic backups scheduled on Linux (Crontab). |
145118
| 1.0.0.18 | 2025/03/19 | Improved terminal messages |
146119
| 1.0.0.19 | 2025/04/22 | Improved terminal messages |
147-
120+
| 1.0.0.21 | 2025/04/29 | ssh support for rsync mirror backups |
121+
| 1.0.0.22 | 2025/04/29 | add installer app |
148122
---
149123

150124
## License

install.sh

+119
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#!/bin/bash
2+
3+
app_name="Backup App"
4+
app_version="v1.0.0.22"
5+
app_date="2025/04/29"
6+
app_author="Junon M."
7+
8+
apps+=("backup")
9+
apps+=("restore")
10+
11+
install_directory="/home/$USER/Installed/backup-app"
12+
13+
media_directory="${install_directory}/media"
14+
15+
print_separator() {
16+
local len=${1:-80}
17+
printf "%*s\n" $len "" | tr ' ' '-'
18+
}
19+
20+
print_app_title() {
21+
print_separator
22+
echo " '${app_name}' ${app_version} - Install"
23+
echo " Date: ${app_date} - Author: ${app_author}"
24+
print_separator
25+
}
26+
27+
find_line() {
28+
29+
local file=$1
30+
local line_to_find=$2
31+
32+
# Check if the file exists
33+
if [ ! -f "$file" ]; then
34+
return 1
35+
fi
36+
37+
# Use grep to find the line
38+
grep -q "$line_to_find" "$file"
39+
}
40+
41+
remove_from_path() {
42+
43+
local file=$1
44+
local line=$2
45+
46+
if find_line "$file" "$line"; then
47+
echo "Line '${line}' found in '${file}' file, removing..."
48+
sed -i "/${line}/d" "${file}"
49+
else
50+
echo "Line '${line}' not found in '${file}' file, no changes"
51+
fi
52+
echo
53+
}
54+
55+
add_to_path() {
56+
57+
local file=$1
58+
local line=$2
59+
60+
if find_line "$file" "$line"; then
61+
echo "line '${line}' is found in '${file}' file, no changes"
62+
else
63+
echo "Inserting the line '${line}' to '${file}' file"
64+
echo "${line}" >> "${file}"
65+
fi
66+
67+
echo
68+
}
69+
70+
print_app_title
71+
echo
72+
echo "Press [ENTER] to install '${app_name}', or [CTRL+C] to exit..."
73+
read
74+
75+
if [ ! -d "${install_directory}" ]; then
76+
echo "Making app installation directory '${install_directory}'"
77+
mkdir -p "${install_directory}"
78+
echo
79+
fi
80+
81+
echo "Installing dependencies, please wait..."
82+
sudo apt install rsync tar -y
83+
84+
echo "Installing audio notification files in '${media_directory}', please wait..."
85+
rsync -avz ./"media/" "${media_directory}"
86+
87+
echo "Installing ${app_name}, please wait..."
88+
89+
for i in ${!apps[@]}
90+
do
91+
from=./"src/${apps[i]}.sh"
92+
to="${install_directory}/${apps[i]}.sh"
93+
echo "Copying '${from}' to '${to}'"
94+
cp "${from}" "${to}"
95+
96+
if [ -L "${install_directory}/${apps[i]}" ]; then
97+
rm "${install_directory}/${apps[i]}"
98+
fi
99+
100+
ln -s "${install_directory}/${apps[i]}.sh" "${install_directory}/${apps[i]}"
101+
done
102+
103+
add_to_path ~/.bashrc "source ~/.paths"
104+
add_to_path ~/.paths "export PATH=\$PATH:${install_directory}"
105+
106+
# echo "Open with gedit"
107+
# gedit ~/.paths
108+
109+
echo "Reload '~/.bashrc' file"
110+
source ~/.bashrc
111+
112+
echo
113+
echo "'${app_name}' successfull installed."
114+
echo
115+
echo "Press [ENTER] to exit..."
116+
read
117+
118+
119+
File renamed without changes.
File renamed without changes.

remove.sh

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/bin/bash
2+
3+
app_name="Backup App"
4+
app_version="v1.0.0.22"
5+
app_date="2025/04/29"
6+
app_author="Junon M."
7+
8+
apps+=("backup")
9+
apps+=("restore")
10+
11+
install_directory="/home/$USER/Installed/backup-app"
12+
13+
14+
print_separator() {
15+
local len=${1:-80}
16+
printf "%*s\n" $len "" | tr ' ' '-'
17+
}
18+
19+
print_app_title() {
20+
print_separator
21+
echo " '${app_name}' ${app_version} - Remove"
22+
echo " Date: ${app_date} - Author: ${app_author}"
23+
print_separator
24+
}
25+
26+
find_line() {
27+
28+
local file=$1
29+
local line_to_find=$2
30+
31+
# Check if the file exists
32+
if [ ! -f "$file" ]; then
33+
return 1
34+
fi
35+
36+
# Use grep to find the line
37+
grep -q "$line_to_find" "$file"
38+
}
39+
40+
remove_from_path() {
41+
42+
local file=$1
43+
local line=$2
44+
45+
if find_line "$file" "$line"; then
46+
echo "Line '${line}' found in '${file}' file, removing..."
47+
sed -i "/${line}/d" "${file}"
48+
else
49+
echo "Line '${line}' not found in '${file}' file, no changes"
50+
fi
51+
echo
52+
}
53+
54+
add_to_path() {
55+
56+
local file=$1
57+
local line=$2
58+
59+
if find_line "$file" "$line"; then
60+
echo "line '${line}' is found in '${file}' file, no changes"
61+
else
62+
echo "Inserting the line '${line}' to '${file}' file"
63+
echo "${line}" >> "${file}"
64+
fi
65+
66+
echo
67+
}
68+
69+
print_app_title
70+
echo
71+
echo "Press [ENTER] to remove App, or [CTRL+C] to exit..."
72+
read
73+
74+
if [ -d "${install_directory}" ]; then
75+
echo "Removing app: '${install_directory}'"
76+
rm -rf "${install_directory}"
77+
fi
78+
79+
echo
80+
echo "Removed!"
81+
echo
82+
echo "Press [ENTER] to exit..."
83+
read
84+
85+
86+

0 commit comments

Comments
 (0)