forked from ungleich-public/ccollect
Added 90% of functionality, added more configuration examples
This commit is contained in:
parent
967556b693
commit
09b10f4776
8 changed files with 44 additions and 14 deletions
45
ccollect.sh
45
ccollect.sh
|
@ -209,16 +209,14 @@ while [ "$i" -lt "$no_shares" ]; do
|
||||||
done < "$c_exclude"
|
done < "$c_exclude"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#
|
|
||||||
# TODO
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# check if maximum number of backups is reached, if so remove
|
# check if maximum number of backups is reached, if so remove
|
||||||
#
|
#
|
||||||
|
|
||||||
# STOPPED!
|
#
|
||||||
count=$(ls "$c_dest/${INTERVALL}.*" | wc -l)
|
# the created directories are named $INTERVALL.$DATE
|
||||||
|
#
|
||||||
|
count=$(ls -d "$c_dest/${INTERVALL}."?* 2>/dev/null | wc -l)
|
||||||
echo "|-> $count backup(s) already exist, keeping $c_intervall backup(s)."
|
echo "|-> $count backup(s) already exist, keeping $c_intervall backup(s)."
|
||||||
|
|
||||||
if [ "$count" -ge "$c_intervall" ]; then
|
if [ "$count" -ge "$c_intervall" ]; then
|
||||||
|
@ -226,11 +224,11 @@ while [ "$i" -lt "$no_shares" ]; do
|
||||||
remove=$(echo $count - $substract | bc)
|
remove=$(echo $count - $substract | bc)
|
||||||
echo "|-> Removing $remove backups..."
|
echo "|-> Removing $remove backups..."
|
||||||
|
|
||||||
ls "$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="$c_dest/$to_remove"
|
dir="$to_remove"
|
||||||
echo "|-> Removing $dir ..."
|
echo "|-> Removing $dir ..."
|
||||||
rm -rf "$dir"
|
echo rm -rf "$dir"
|
||||||
done < "$TMP"
|
done < "$TMP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -238,14 +236,35 @@ while [ "$i" -lt "$no_shares" ]; do
|
||||||
# clone the old directory with hardlinks
|
# clone the old directory with hardlinks
|
||||||
#
|
#
|
||||||
|
|
||||||
|
destination_date=$(date +%Y-%m-%d-%H:%M)
|
||||||
|
destination_dir="$c_dest/${INTERVALL}.${destination_date}/"
|
||||||
|
|
||||||
|
last_dir=$(ls -d "$c_dest/${INTERVALL}."?* 2>/dev/null | sort -n | tail -n 1)
|
||||||
|
|
||||||
|
# only copy if there exists a directory
|
||||||
|
if [ "$last_dir" ]; then
|
||||||
|
echo cp -al "$last_dir" "$destination_dir"
|
||||||
|
else
|
||||||
|
mkdir "$destination_dir"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
errecho "Creating backup directory failed. Skipping backup."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
#
|
#
|
||||||
# the rsync part
|
# the rsync part
|
||||||
# --delete --numeric-ids --relative --delete-excluded
|
# options stolen shameless from rsnapshot
|
||||||
#
|
#
|
||||||
|
|
||||||
# STOPPED!
|
echo rsync -a --delete --numeric-ids --relative --delete-excluded \
|
||||||
destination_dir=$(date +%Y-%m-%d)
|
$EXCLUDE $VERBOSE $EXCLUDE "$source" "$destination_dir"
|
||||||
echo rsync -a --delete $EXCLUDE $VERBOSE $EXCLUDE "$source" "$c_dest/${INTERVALL}.${destination_dir}"
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
errecho "rsync failed, backup most likely broken"
|
||||||
|
continue
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
#
|
#
|
||||||
|
|
1
conf/defaults/intervalls/daily
Normal file
1
conf/defaults/intervalls/daily
Normal file
|
@ -0,0 +1 @@
|
||||||
|
28
|
3
conf/sources/share2/exclude
Normal file
3
conf/sources/share2/exclude
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
openvpn-2.0.1.tar.gz
|
||||||
|
nicht_reinnehmen
|
||||||
|
etwas mit leerzeichenli
|
1
conf/sources/share2/intervalls/daily
Normal file
1
conf/sources/share2/intervalls/daily
Normal file
|
@ -0,0 +1 @@
|
||||||
|
2
|
1
conf/sources/share2/source
Normal file
1
conf/sources/share2/source
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/home/nico/vpn
|
1
conf/sources/source-without-intervall/exclude
Normal file
1
conf/sources/source-without-intervall/exclude
Normal file
|
@ -0,0 +1 @@
|
||||||
|
manage
|
1
conf/sources/source-without-intervall/source
Normal file
1
conf/sources/source-without-intervall/source
Normal file
|
@ -0,0 +1 @@
|
||||||
|
nico@creme.schottelius.org:bin
|
3
conf/sources/testshare/exclude
Normal file
3
conf/sources/testshare/exclude
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
openvpn-2.0.1.tar.gz
|
||||||
|
nicht_reinnehmen
|
||||||
|
etwas mit leerzeichenli
|
Loading…
Reference in a new issue