-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstba.sh
More file actions
executable file
·98 lines (84 loc) · 3.44 KB
/
Copy pathstba.sh
File metadata and controls
executable file
·98 lines (84 loc) · 3.44 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#! /bin/bash
# # STart BAckup
#
# A startup script for [StoreBackup](http://storebackup.org/) (the remarkable
# GNU backup program written by: Heinz-Josef Claes).
#
# Copyright 2016 Willem Oosting
#
# >This program is free software: you can redistribute it and/or modify
# >it under the terms of the GNU General Public License as published by
# >the Free Software Foundation, either version 3 of the License, or
# >(at your option) any later version.
# >
# >This program is distributed in the hope that it will be useful,
# >but WITHOUT ANY WARRANTY; without even the implied warranty of
# >MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# >GNU General Public License for more details.
# >
# >You should have received a copy of the GNU General Public License
# >along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# FORK ME AT GITHUB: https://github.com/woosting/stba
# CONFIGURATION
SOURCEDIR="${HOME}/storeBackup/sources" # Assuming the sources dir countains symbolic links that point to the real sources directories.
LINKS2SOURCES="y" # Assuming the sources dir contains links to point to the (possibly various) sources.
TARGETDIR="${HOME}/storeBackup/target/target" # Assuming the target dir contains a symbolic link, "target", that points to the real target directory.
DELAY="n" # Assuming everything should be executed in one go.
# ^^^ NOTE: THE AFOREMENTIONED SETTINGS OVERRULE THEIR EQUIVALENTS IN A SUPPLIED CONFIGURATION! vvv
CONFIGFILE="${HOME}/storeBackup/storeBackup.cfg" # Rest is taken from the config file, if supplied (otherwise storeBackup configs are used).
# FUNCTION DEFINITION
function printHelp () {
echo -e "STBA - STart BAckup (2016, GNU GENERAL PUBLIC LICENSE)\n"
echo -e "USAGE: stba [[-s \"/path/sourcedir\"] [-l y|n ] [-t \"/path/target\"] [-c \"/path/configfile\"] [-d] ] | [-h]\n"
echo -e "Arguments:"
echo -e " -s (source) Overrides the default source directory (${SOURCEDIR})."
echo -e " -l (links) Overrides the default followLinks (${LINKS2SOURCES})."
echo -e " -t (target) Overrides the default target directory (${TARGETDIR})."
echo -e " -c (config) Overrides the default config file (${CONFIGFILE})."
echo -e " -d (delay) Overrides both lateLinks and lateCompress set in (${CONFIGFILE})."
echo -e " -h (help) Prints this helptext."
}
# INITIALISATION
PATH=${PATH}:/usr/local/bin
while getopts s:l:t:c:dh option
do
case "${option}"
in
s) SOURCEDIR=${OPTARG};;
l) LINK2SOURCES=${OPTARG};;
t) TARGETDIR=${OPTARG};;
c) CONFIGFILE=${OPTARG};;
d) DELAY="y";;
h)
printHelp
exit 0
;;
\?)
printHelp
exit 1
;;
esac
done
if [ "${LINKS2SOURCES}" == "y" ] || [ "${LINKS2SOURCES}" == "Y" ] || [ "${LINKS2SOURCES}" == "yes" ] || [ "${LINKS2SOURCES}" == "Yes" ] || [ "${LINKS2SOURCES}" == "YES" ] ; then
L2SSUPPL="/*"
L2SDEPTH="--followLinks 1"
else
L2SSUPPL=""
L2SDEPTH="--followLinks 0"
fi
if [ "${DELAY}" = "y" ]; then
DELAY="--lateLinks --lateCompress"
else
DELAY=""
fi
# EXECUTION
dirp -v -e -r "${SOURCEDIR}${L2SSUPPL}" -w "${TARGETDIR}" && \
storeBackup --sourceDir ${SOURCEDIR} --backupDir ${TARGETDIR} ${L2SDEPTH} ${DELAY} -f ${CONFIGFILE}
rc=$?;
if [[ $rc != 0 ]]; then
echo -e "\nERRORS"
exit 1
else
echo -e "\nCOMPLETED"
fi