#!/bin/bash

	DST="/home/backup/repos"
	DATE=$(date +"%Y%m%d")
	LOG_BACKUP="/var/log/backup_edokumenty"
	ENV="edokumenty"

	DATESTART=$(date +"%Y-%m-%d %H:%M:%S")

	mkdir -p ${LOG_BACKUP}
	
	if [ -d $DST ] 
	then
		sleep 1
		else
			mkdir $DST
			fi

	echo "Start: Backup repos ${ENV} - ${DATESTART}"  >> ${LOG_BACKUP}/backup_repos_${ENV}.log

		svnadmin dump /home/${ENV}/repos > ${DST}/repos_${DATE}.dump

		#Usunięcie starszych niż 2 dni rzutów repos
		find ${DST} -name "repos_*.dump" -mtime +1 -type f -delete

	 DATEEND=$(date +"%Y-%m-%d %H:%M:%S")


	echo "Koniec: Backup repos ${ENV} - ${DATEEND}" >> ${LOG_BACKUP}/backup_repos_${ENV}.log
