forked from ungleich-public/ccollect
Completed parallelization
This commit is contained in:
parent
34c3d4455e
commit
0231c18401
1 changed files with 17 additions and 20 deletions
37
ccollect.sh
37
ccollect.sh
|
@ -208,17 +208,16 @@ while [ "$i" -lt "$no_shares" ]; do
|
||||||
|
|
||||||
echo "Beginning to backup this source ..."
|
echo "Beginning to backup this source ..."
|
||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Standard configuration checks
|
# Standard configuration checks
|
||||||
#
|
#
|
||||||
if [ ! -e "$backup" ]; then
|
if [ ! -e "$backup" ]; then
|
||||||
echo "Source does not exist."
|
echo "Source does not exist."
|
||||||
continue
|
exit 1
|
||||||
fi
|
fi
|
||||||
if [ ! -d "$backup" ]; then
|
if [ ! -d "$backup" ]; then
|
||||||
echo "\"$name\" is not a cconfig-directory. Skipping."
|
echo "\"$name\" is not a cconfig-directory. Skipping."
|
||||||
continue
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -230,8 +229,8 @@ while [ "$i" -lt "$no_shares" ]; do
|
||||||
c_intervall=$D_INTERVALL
|
c_intervall=$D_INTERVALL
|
||||||
|
|
||||||
if [ -z "$c_intervall" ]; then
|
if [ -z "$c_intervall" ]; then
|
||||||
errecho "Default and source specific intervall missing. Skipping."
|
echo "Default and source specific intervall missing. Skipping."
|
||||||
continue
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -246,19 +245,19 @@ while [ "$i" -lt "$no_shares" ]; do
|
||||||
# next configuration checks
|
# next configuration checks
|
||||||
#
|
#
|
||||||
if [ ! -f "$c_source" ]; then
|
if [ ! -f "$c_source" ]; then
|
||||||
stdecho "Source description $c_source is not a file. Skipping."
|
echo "Source description $c_source is not a file. Skipping."
|
||||||
continue
|
exit 1
|
||||||
else
|
else
|
||||||
source=$(cat "$c_source")
|
source=$(cat "$c_source")
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
stdecho "Skipping: Source $c_source is not readable"
|
stdecho "Skipping: Source $c_source is not readable"
|
||||||
continue
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -d "$c_dest" ]; then
|
if [ ! -d "$c_dest" ]; then
|
||||||
errecho "Destination $c_dest does not link to a directory. Skipping"
|
echo "Destination $c_dest does not link to a directory. Skipping"
|
||||||
continue
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# exclude
|
# exclude
|
||||||
|
@ -282,17 +281,17 @@ while [ "$i" -lt "$no_shares" ]; do
|
||||||
|
|
||||||
# the created directories are named $INTERVALL.$DA
|
# the created directories are named $INTERVALL.$DA
|
||||||
count=$(ls -d "$c_dest/${INTERVALL}."?* 2>/dev/null | wc -l)
|
count=$(ls -d "$c_dest/${INTERVALL}."?* 2>/dev/null | wc -l)
|
||||||
stdecho "Currently $count backup(s) exist, total keeping $c_intervall backup(s)."
|
echo "Currently $count backup(s) exist, total keeping $c_intervall backup(s)."
|
||||||
|
|
||||||
if [ "$count" -ge "$c_intervall" ]; then
|
if [ "$count" -ge "$c_intervall" ]; then
|
||||||
substract=$(echo $c_intervall - 1 | bc)
|
substract=$(echo $c_intervall - 1 | bc)
|
||||||
remove=$(echo $count - $substract | bc)
|
remove=$(echo $count - $substract | bc)
|
||||||
stdecho "Removing $remove backup(s)..."
|
echo "Removing $remove backup(s)..."
|
||||||
|
|
||||||
ls -d "$c_dest/${INTERVALL}."?* | sort -n | head -n $remove > "$TMP"
|
ls -d "$c_dest/${INTERVALL}."?* | sort -n | head -n $remove > "$TMP"
|
||||||
while read to_remove; do
|
while read to_remove; do
|
||||||
dir="$to_remove"
|
dir="$to_remove"
|
||||||
stdecho "Removing $dir ..."
|
echo "Removing $dir ..."
|
||||||
rm -rf "$dir" 2>&1 | add_name
|
rm -rf "$dir" 2>&1 | add_name
|
||||||
done < "$TMP"
|
done < "$TMP"
|
||||||
fi
|
fi
|
||||||
|
@ -307,7 +306,7 @@ while [ "$i" -lt "$no_shares" ]; do
|
||||||
last_dir=$(ls -d "$c_dest/${INTERVALL}."?* 2>/dev/null | sort -n | tail -n 1)
|
last_dir=$(ls -d "$c_dest/${INTERVALL}."?* 2>/dev/null | sort -n | tail -n 1)
|
||||||
|
|
||||||
# give some info
|
# give some info
|
||||||
stdecho "Beginning to backup, this may take some time..."
|
echo "Beginning to backup, this may take some time..."
|
||||||
|
|
||||||
# only copy if a directory exists
|
# only copy if a directory exists
|
||||||
if [ "$last_dir" ]; then
|
if [ "$last_dir" ]; then
|
||||||
|
@ -319,8 +318,8 @@ while [ "$i" -lt "$no_shares" ]; do
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
errecho "Creating/cloning backup directory failed. Skipping backup."
|
echo "Creating/cloning backup directory failed. Skipping backup."
|
||||||
continue
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -335,12 +334,10 @@ while [ "$i" -lt "$no_shares" ]; do
|
||||||
"$source" "$destination_dir"
|
"$source" "$destination_dir"
|
||||||
|
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
errecho "rsync failed, backup may be broken (see rsync errors)"
|
echo "rsync failed, backup may be broken (see rsync errors)"
|
||||||
continue
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exit 0
|
|
||||||
|
|
||||||
echo "Successfully finished backup."
|
echo "Successfully finished backup."
|
||||||
|
|
||||||
) | add_name
|
) | add_name
|
||||||
|
|
Loading…
Reference in a new issue