-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtar_Filesystem.sh
More file actions
executable file
·82 lines (66 loc) · 1.76 KB
/
tar_Filesystem.sh
File metadata and controls
executable file
·82 lines (66 loc) · 1.76 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
. /links/bin/lib/bkp_functions.sh
tag=$(date +'%d')
monat=$(date +'%m')
jahr=$(date +'%y')
determineDistribution
determineSystemByHostname
usage ()
{
echo "call ${0} [-f <FILESYSTEMMOUNTPOINT> ] "
echo "samples are:"
echo "FILESYSTEMMOUNTPOINT=/"
exit 0;
}
#######################################
# main starts here
# intialize Parameters (may be overwritten with input parameter)
FILESYSTEMMOUNTPOINT="/"
while getopts ":f:h" OPTNAME
do
case "${OPTNAME}" in
"h")
echo "Option ${OPTNAME} is specified"
usage
exit 0;
;;
"f")
echo "Option ${OPTNAME} is specified"
FILESYSTEMMOUNTPOINT=${OPTARG}
;;
*)
# Should not occur
echo "Unknown error while processing options"
;;
esac
#echo "OPTIND is now $OPTIND"
done
TARGETPATH="/links/sysbkp"
if [ ${SYSTEM} = "tpibm" ]
then
TARGETPATH="/links/sysbkp"
if [ ! -f ${TARGETPATH}/doNotDelete ]
then
TARGETPATH="/local/data/ssd_backup/sysbkp"
fi
fi
if [ ${FILESYSTEMMOUNTPOINT} = "/" ]
then
TARGETFILENAME=${TARGETPATH}/${SYSTEM}_${DISTRIBUTION}_${jahr}${monat}${tag}.tgz
else
FILESYTEM_FILENAME=${FILESYSTEMMOUNTPOINT//'/'/_} #replace / with _
TARGETFILENAME=${TARGETPATH}/${SYSTEM}-${FILESYTEM_FILENAME}-${jahr}${monat}${tag}.tgz
fi
echo "DISTRIBUTION = " ${DISTRIBUTION}
echo "TARGETFILENAME = " ${TARGETFILENAME}
if [ -z ${SYSTEM} ]
then
echo " host ${HOSTNAME} not known, not doing backup"
else
echo "starting backup on $(date +%H:%M:%S)"
CMD="tar --selinux --acls --xattrs -cpf ${TARGETFILENAME} --directory ${FILESYSTEMMOUNTPOINT} --use-compress-program=pigz --one-file-system --numeric-owner --exclude=proc/* --exclude=mnt/* --exclude=*/lost+found --exclude=tmp/* ."
echo ${CMD}
#`${CMD}`
($CMD)
echo "finished backup on $(date +%H:%M:%S)"
fi