-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_shell_backup.sh
More file actions
executable file
·38 lines (31 loc) · 1.25 KB
/
create_shell_backup.sh
File metadata and controls
executable file
·38 lines (31 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash # Specifies the script should be run using the Bash shell
<<info
This shell script performs a backup by compressing a given source directory into a zip file.
Usage:
./backup.sh <source> <destination>
Arguments:
<source> - Path of the folder to be backed up
<destination> - Path where the zip backup should be saved
info
# ---------------------------
# 📂 Assign Input Arguments
# ---------------------------
src=$1 # First argument passed to the script: Source directory to back up
dest=$2 # Second argument: Destination directory where backup will be stored
# ---------------------------
# ⏳ Generate Timestamp
# ---------------------------
timestamp=$(date '+%Y-%m-%d-%H-%M') # Current date and time used for naming the backup file
# ---------------------------
# 📦 Create ZIP Archive
# ---------------------------
zip -r "$dest/backup-$timestamp.zip" $src > /dev/null
# Creates a compressed zip of the source directory
# -r means recursive (include all files and subdirectories)
# Output is redirected to /dev/null to suppress details
# ---------------------------
# ✅ Final Output
# ---------------------------
echo "!! Backup Done !!"
echo "Source = $src"
echo "Destination location = $dest/backup-$timestamp.zip"