-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added solution.md for Day-05 with and sample applied images #337
Open
Amitabh-DevOps
wants to merge
6
commits into
LondheShubham153:master
Choose a base branch
from
Amitabh-DevOps:feat/day05
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
41fea0a
Added Solution.md with Images
Amitabh-DevOps 3381635
Added Solution.md with Images
Amitabh-DevOps f105c77
Updated solution.md for demo
Amitabh-DevOps 31cb40a
Updated solution.md for demo
Amitabh-DevOps 0e4fe08
Added solution.md with images
Amitabh-DevOps 892b623
Added solution.md with images
Amitabh-DevOps File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,32 +10,137 @@ | |
|
||
**Answer** | ||
|
||
![image](https://github.com/Bhavin213/90DaysOfDevOps/blob/master/2024/day05/image/task%201.png) | ||
![image](https://github.com/Bhavin213/90DaysOfDevOps/blob/master/2024/day05/image/task%201-2.png) | ||
![image](https://github.com/Bhavin213/90DaysOfDevOps/blob/master/2024/day05/image/task%201-3.png) | ||
- Creating createDirectories.sh and adding below content : | ||
|
||
``` bash | ||
|
||
#!/bin/bash | ||
|
||
<<Info | ||
Author : Amitabh Soni | ||
Date : 25/11/24 | ||
Description : This script takes three arguments and creates a specified number of directories at once. | ||
|
||
Example : When executed as ./createDirectories.sh day 1 90, it creates 90 directories as day1, day2, day3, ... day90. | ||
Info | ||
|
||
# For loop to create directories iteratively | ||
for i in $(seq $2 $3); do | ||
mkdir "$1$i" | ||
done | ||
|
||
``` | ||
|
||
![task1.1](image/task1.1.png) | ||
|
||
|
||
- createDirectories.sh | ||
|
||
![task1.2](image/task1.2.png) | ||
|
||
2. **Create a Script to Backup All Your Work:** | ||
- Backups are an important part of a DevOps Engineer's day-to-day activities. The video in the references will help you understand how a DevOps Engineer takes backups (it can feel a bit difficult but keep trying, nothing is impossible). | ||
|
||
**Answer** | ||
|
||
![image](https://github.com/Bhavin213/90DaysOfDevOps/blob/master/2024/day05/image/task%202.png) | ||
![image](https://github.com/Bhavin213/90DaysOfDevOps/blob/master/2024/day05/image/task%202-1.png) | ||
|
||
- Creating a `backup.sh` file and executing after adding the below content: | ||
|
||
```bash | ||
#!/bin/bash | ||
|
||
<<Info | ||
Author : Amitabh Soni | ||
Date : 25/11/25 | ||
Description : This script will take backup of any directory or file and store it in the backup directory: /home/ubuntu/Day-05/backup | ||
Info | ||
|
||
# Creating a function for backup creation | ||
function create_backup() { | ||
# Timestamp for backup naming | ||
timestamp=$(date '+%Y-%m-%d_%H-%M-%S') | ||
|
||
# Target directory where backups are stored | ||
target_dir="/home/ubuntu/Day-05/backup" | ||
|
||
# Backup filename | ||
backup_file="${target_dir}/backup_${timestamp}.zip" | ||
|
||
# Create zip backup | ||
zip -r "$backup_file" "$1" | ||
|
||
# Checking if the previous command successfully ran or not | ||
if [ $? -eq 0 ]; then | ||
echo "Backup created: ${backup_file}" | ||
else | ||
echo "Error: Failed to create backup." | ||
return 1 | ||
fi | ||
} | ||
|
||
create_backup "$1" | ||
|
||
``` | ||
Comment on lines
+48
to
+82
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Add security considerations to backup script Consider adding these security improvements:
# Create zip backup
zip -r "$backup_file" "$1"
+
+# Set secure permissions on backup file
+chmod 600 "$backup_file"
|
||
|
||
![task2.1](image/task2.1.png) | ||
|
||
|
||
- backup.sh : | ||
|
||
![task2.2](image/task2.2.png) | ||
|
||
|
||
- Output image : | ||
|
||
![task2.3](image/task2.3.png) | ||
|
||
3. **Read About Cron and Crontab to Automate the Backup Script:** | ||
- Cron is the system's main scheduler for running jobs or tasks unattended. A command called crontab allows the user to submit, edit, or delete entries to cron. A crontab file is a user file that holds the scheduling information. | ||
|
||
**Answer** | ||
|
||
![image](https://github.com/Bhavin213/90DaysOfDevOps/blob/master/2024/day05/image/task%203.png) | ||
![image](https://github.com/Bhavin213/90DaysOfDevOps/blob/master/2024/day05/image/task%203-1.png) | ||
- Editing crontab for auto backup : | ||
|
||
![task3.1](image/task3.1.png) | ||
|
||
|
||
- setting a backup of Day-04 in every minute : | ||
|
||
![task3.2](image/task3.2.png) | ||
|
||
|
||
- Ensuring whether it creates backup in one minute or not : | ||
|
||
![task3.3](image/task3.3.png) | ||
|
||
|
||
- checking realtime update in backup dir through 'watch ls' command : | ||
|
||
![task3.4](image/task3.4.png) | ||
|
||
|
||
- It works for every minute : | ||
|
||
![task3.5](image/task3.5.png) | ||
|
||
|
||
- Final check for backup : | ||
|
||
![task3.6](image/task3.6.png) | ||
|
||
4. **Read About User Management:** | ||
- A user is an entity in a Linux operating system that can manipulate files and perform several other operations. Each user is assigned an ID that is unique within the system. IDs 0 to 999 are assigned to system users, and local user IDs start from 1000 onwards. | ||
- Create 2 users and display their usernames. | ||
|
||
**Answer** | ||
|
||
![image](https://github.com/Bhavin213/90DaysOfDevOps/blob/master/2024/day05/image/task%204.png) | ||
- Creating users and printing there names : | ||
|
||
![task4.1](image/task4.1.png) | ||
|
||
|
||
- Setting up password the new users : | ||
|
||
![task4.2](image/task4.2.png) | ||
|
||
|
||
[LinkedIn](https://www.linkedin.com/in/bhavin-savaliya/). | ||
[LinkedIn](https://www.linkedin.com/in/amitabh-devops/). |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add input validation and error handling to the script
The script needs several essential improvements for robustness:
📝 Committable suggestion