-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.sh
More file actions
30 lines (22 loc) · 727 Bytes
/
functions.sh
File metadata and controls
30 lines (22 loc) · 727 Bytes
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
#!/bin/bash
# This bash script is used to backup a user's home directory to /tmp/.
user=$(whoami)
input=/home/$user
output=/tmp/${user}_home_$(date +%Y-%m-%d_%H%M%S).tar.gz
# The function total_files reports a total number of files for a given directory.
function total_files {
find \$1 -type f | wc -l
}
# The function total_directories reports a total number of directories
# for a given directory.
function total_directories {
find \$1 -type d | wc -l
}
tar -czf $output $input 2> /dev/null
echo -n "Files to be included:"
total_files $input
echo -n "Directories to be included:"
total_directories $input
echo "Backup of $input completed!"
echo "Details about the output backup file:"
ls -l $output