-
Notifications
You must be signed in to change notification settings - Fork 0
/
backups.sh
41 lines (32 loc) · 843 Bytes
/
backups.sh
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
39
40
41
#!/bin/sh
# Switch to script directory
dirToNavigate=$(dirname "$0")
cd $dirToNavigate
# Ensure script is executed with parameter
fileName=$1
if [ "$#" -eq 0 ]; then
echo "Backups shall be called with a filename that contains a list of configuration files"
exit
fi
if [ ! -f "$fileName" ]; then
echo "Configurations list file doesn't exist : $fileName"
exit
fi
## Create data directory
dbDir=./.backup.db
if [ ! -d $dbDir ]; then
mkdir $dbDir
fi
# Convert configurations list file
# Convert DOS to Unix newline char(s)
confFile=$(echo $fileName | awk -F "/" '{print $NF}')
tmpConf="$dbDir/$confFile.conf"
tr -d '\015' < $fileName > "$tmpConf"
fileName="$tmpConf"
# Remove first software arg
shift
# Call each backup
while IFS='' read -r line || [[ -n "$line" ]]; do
i=${backups[$iK]}
./backup.sh "$line" "$@"
done < "$fileName"