+echo "Done"
+echo
+
+#
+# Delete old backups
+#
+if (( ${maxNrOfBackups} != 0 ))
+then
+ nrOfBackups=$(ls -l ${backupMainDir} | grep -c ^d)
+
+ if (( ${nrOfBackups} > ${maxNrOfBackups} ))
+ then
+ echo "Removing old backups..."
+ ls -t ${backupMainDir} | tail -$(( nrOfBackups - maxNrOfBackups )) | while read dirToRemove; do
+ echo "${dirToRemove}"
+ rm -r ${backupMainDir}/${dirToRemove}
+ echo "Done"
+ echo
+ done
+ fi
+fi