Commit 7839bc2c authored by Bjoern Nachtwey's avatar Bjoern Nachtwey
Browse files

merged scrits backup-daily-*.sh to OC-daily-selective-backup.sh

parent b6143f5a
#! /bin/bash
today=$(date "+%F" -d yesterday)
export LANG=en_US
export LC_ALL=en_US
# check for given date as $1
if [[ $1 ]]
then
today=$1
else
today=$(date "+%F")
fi
# create today's folder and switch to it
if [[ ! -d $today ]]
then
mkdir $today
fi
cd $today
## settings
# initial path
bpath=/mnt/oc_stor_userdata
optfile=/tsm/owncloud.opt
optfile=/tsm/ocnode/owncloud.opt
# number of parallel jobs
numjobs=25
chunknum=$(expr $numjobs \* 10)
##
## check for snapshot and filelist
##
# get latest snapshot for SNAPSHOTROOT
#ssr=$(find $bpath/.snapshot/ -maxdepth 1 -daystart -ctime 1 -name "snap_daily*")
ssr=$(ls -d $bpath/.snapshot/snap_daily.$today*)
if [[ ! $ssr ]]
then
echo "no actual daily snapshot";
echo "no actual daily snapshot" | tee -a out.log
exit 2
else
echo "latest snapshot: $ssr"
echo "latest snapshot: $ssr" | tee -a out.log
fi
# get latest filelist
......@@ -33,23 +44,41 @@ filelist=$(ls -d $bpath/tsm/GWDG_owncloud_incremental_filelist_$today* )
if [[ ! $filelist ]]
then
echo "no actual filelist"
echo "no actual filelist" | tee -a out.log
exit 3
else
echo "latest filelist: $filelist"
echo "latest filelist: $filelist" | tee -a out.log
fi
##
## split file list
## split filelist
##
split -d -a3 -n r/$chunknum $filelist chunk.
##
## do parallel backup
##
ls chunk* | parallel -j $numjobs --results $today dsmc sel -filelist={} -wildcardsareliteral -quotessareliteral -snapshotroot=$ssr -optfile=$optfile -errorlogname=$today/errlog.{}
echo "----" > out.log
date >> out.log
echo "----" >> out.log
$(ls chunk* | parallel -j $numjobs --results $today dsmc seld -filelist={} -snapshotroot=$ssr -optfile=$optfile -errorlogname=errlog.{} ) >> out.log
echo "----" >> out.log
date >> out.log
echo "----" >> out.log
##
## clean up
##
rm -f chunk.*
##
## collect stats
##
echo Total number of objects inspected: $(grep "Total number of objects inspected" out.log | sed -e 's/,//g' | awk -F ':' '{sum+=$2} END {print sum}') >> ../$today.stats
echo Total number of objects backed up: $(grep "Total number of objects backed up" out.log | sed -e 's/,//g' | awk -F ':' '{sum+=$2} END {print sum}') >> ../$today.stats
echo Total number of objects updated : $(grep "Total number of objects updated" out.log | sed -e 's/,//g' | awk -F ':' '{sum+=$2} END {print sum}') >> ../$today.stats
echo Total number of objects failed : $(grep "Total number of objects failed" out.log | sed -e 's/,//g' | awk -F ':' '{sum+=$2} END {print sum}') >> ../$today.stats
echo ANS4005 errors : $(grep ANS4005E out.log | wc -l) >> ../$today.stats
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment