Skip to content

Commit abf7ca1

Browse files
authored
Update README.md
1 parent 30d9b38 commit abf7ca1

File tree

1 file changed

+45
-74
lines changed

1 file changed

+45
-74
lines changed

README.md

Lines changed: 45 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,97 @@
11

2-
# Debian System Backup and Restore Script
2+
# Debian System Backup and Restore Script (Version 2.0)
33

4-
This repository contains a shell script to back up and restore important system elements of a Debian-based system. This is useful for creating a rollback point before making significant changes to the system.
4+
This repository contains a shell script for backing up and restoring key system elements of a Debian-based system. It is useful for creating a recovery point before making significant changes to the system.
55

66
## Features
77
- Backs up the list of installed packages.
88
- Backs up configuration files in `/etc`.
9-
- Optional: Backs up the entire filesystem (excluding the backup directory itself).
9+
- Optionally: Backs up the entire file system (with configurable exclusions).
1010
- Provides a restore function to revert the system to the saved state.
11+
- Logs all actions in detail.
1112

12-
## Prerequisites
13+
## Requirements
1314
- A Debian-based system (e.g., Debian, Ubuntu).
1415
- Sufficient disk space for the backup.
1516

1617
## Usage
1718

18-
### 1. Clone the Repository
19+
### 1. Clone the repository
1920
Clone this repository to your local machine:
2021
```sh
2122
git clone https://github.com/VolkanSah/Debian-System-Backup-and-Restore-Script
2223
cd Debian-System-Backup-and-Restore-Script
2324
```
2425

25-
### 2. Make the Script Executable
26-
Ensure the script has execute permissions:
26+
### 2. Make the script executable
27+
Ensure the script has execution permissions:
2728
```sh
2829
chmod +x backup_script.sh
2930
```
3031

31-
### 3. Run the Backup Script
32-
To create a backup, run the script without any arguments:
32+
### 3. Run the backup script
33+
To create a backup, run the script with the `backup` argument:
3334
```sh
34-
./backup_script.sh
35+
./backup_script.sh backup
3536
```
37+
For a full file system backup:
38+
```sh
39+
./backup_script.sh backup full
40+
```
41+
3642
This will:
37-
- Create a backup directory with a timestamp.
43+
- Create a timestamped backup directory.
3844
- Save the list of installed packages to `installed_packages.list`.
39-
- Compress and save configuration files from `/etc` to `etc_backup.tar.gz`.
40-
- Optionally, you can uncomment the lines in the script to back up the entire filesystem.
45+
- Compress and store configuration files from `/etc` into `etc_backup.tar.gz`.
46+
- Optionally back up the entire file system (if "full" is specified).
4147

42-
### 4. Restore from a Backup
48+
### 4. Restore from a backup
4349
To restore the system from a backup, run the script with the `restore` argument and the path to the backup directory:
4450
```sh
4551
./backup_script.sh restore /path/to/backup_directory
4652
```
53+
For a full system restore:
54+
```sh
55+
./backup_script.sh restore /path/to/backup_directory full
56+
```
57+
4758
This will:
4859
- Restore the list of installed packages.
4960
- Extract and restore configuration files from `etc_backup.tar.gz`.
50-
- Optionally, uncomment the lines to restore the entire filesystem.
61+
- Optionally restore the entire file system (if "full" is specified).
5162

5263
## Script Details
5364

54-
### Backup Script
55-
```bash
56-
#!/bin/bash
57-
58-
# Create backup directory
59-
BACKUP_DIR="/backup/$(date +%Y%m%d_%H%M%S)"
60-
mkdir -p "$BACKUP_DIR"
61-
62-
# Save the list of installed packages
63-
dpkg --get-selections > "$BACKUP_DIR/installed_packages.list"
64-
echo "Package list saved to $BACKUP_DIR/installed_packages.list"
65-
66-
# Backup configuration files
67-
tar czf "$BACKUP_DIR/etc_backup.tar.gz" /etc
68-
echo "Configuration files saved to $BACKUP_DIR/etc_backup.tar.gz"
69-
70-
# Optional: Backup the entire filesystem (can consume a lot of space)
71-
# tar czf "$BACKUP_DIR/full_backup.tar.gz" --exclude="$BACKUP_DIR" /
72-
73-
# Backup complete
74-
echo "Backup complete. All important files are saved in $BACKUP_DIR."
75-
76-
# Restore function
77-
restore() {
78-
BACKUP_DIR="$1"
79-
if [ -z "$BACKUP_DIR" ]; then
80-
echo "Please specify the backup directory."
81-
exit 1
82-
fi
83-
84-
# Restore the list of installed packages
85-
sudo dpkg --set-selections < "$BACKUP_DIR/installed_packages.list"
86-
sudo apt-get -y dselect-upgrade
87-
echo "Package list restored."
88-
89-
# Restore configuration files
90-
tar xzf "$BACKUP_DIR/etc_backup.tar.gz" -C /
91-
echo "Configuration files restored."
92-
93-
# Optional: Restore the entire filesystem
94-
# tar xzf "$BACKUP_DIR/full_backup.tar.gz" -C /
95-
}
96-
97-
# Automatic restore if an argument is provided
98-
if [ "$1" == "restore" ]; then
99-
restore "$2"
100-
fi
101-
```
65+
The updated script offers the following improvements:
66+
- Detailed logging of all actions.
67+
- Configurable options for important settings.
68+
- An exclusion list for full backups.
69+
- Improved structure with separate functions for backup and restore.
70+
- Flexible options for normal and full backup/restore.
71+
- Enhanced error handling and checks.
10272

10373
## Recommendations
104-
- **Error Handling**: Add error handling and checks for available disk space before proceeding with the backup.
105-
- **Notifications**: Integrate notifications (e.g., via email) to inform you upon successful backup or restoration.
74+
- **Error Handling**: The script now includes basic error handling. Consider adding further checks, such as for available disk space.
75+
- **Notifications**: Integrate notifications (e.g., via email) to inform you of successful backups or restores.
10676

10777
## License
108-
This project is licensed under the GPLv3 License. See the `LICENSE` file for details.
78+
This project is licensed under the GPLv3 license. See the `LICENSE` file for details.
10979

11080
## Contributing
111-
Contributions are welcome! Please open an issue or submit a pull request for any improvements or suggestions.
81+
Contributions are welcome! Please open an issue or submit a pull request for improvements or suggestions.
11282

11383
## Contact
114-
For any questions or support, please open an issue in the repository.
84+
For questions or support, please open an issue in the repository.
11585

116-
## Your Support
117-
If you find this project useful and want to support it, there are several ways to do so:
86+
## Supporting the Project
87+
If you find this project helpful and would like to support it, there are several ways to do so:
11888

119-
- If you find the white paper helpful, please it on GitHub. This helps make the project more visible and reach more people.
120-
- Become a Follower: If you're interested in updates and future improvements, please follow my GitHub account. This way you'll always stay up-to-date.
121-
- Learn more about my work: I invite you to check out all of my work on GitHub and visit my developer site https://volkansah.github.io. Here you will find detailed information about me and my projects.
89+
- If you find this script useful, please give it a ⭐ on GitHub. This helps make the project more visible and reach more people.
90+
- Follow me: If you're interested in updates and future improvements, please follow my GitHub account to stay informed.
91+
- Learn more about my work: I invite you to view all my work on GitHub and visit my developer website at https://volkansah.github.io. There, you'll find detailed information about me and my projects.
12292
- Share the project: If you know someone who could benefit from this project, please share it. The more people who can use it, the better.
123-
**If you appreciate my work and would like to support it, please visit my [GitHub Sponsor page](https://github.com/sponsors/volkansah). Any type of support is warmly welcomed and helps me to further improve and expand my work.**
93+
94+
**If you appreciate my work and would like to support it, please visit my [GitHub Sponsor page](https://github.com/sponsors/volkansah). Any kind of support is greatly appreciated and helps me improve and expand my work.**
12495

12596
Thank you for your support! ❤️
12697

0 commit comments

Comments
 (0)