# Backup date

today=$(date "+%Y_%m_%d-%H_%M_%S")

echo "Current date: $today"

# build up filename

# destination folder (change to your own needs)

#BACKUP_FOLDER=/tmp
BACKUP_FOLDER=/mnt/Externo/copiasFF

file_name=$BACKUP_FOLDER/bkup_fireflyiii
new_name=$file_name-$today.sql
echo "Backup file name: " "$new_name"

sudo kubectl --kubeconfig /home/creylopez/.kube/config exec `kubectl --kubeconfig /home/creylopez/.kube/config get pod -n firefly|grep iii-mysql|cut -f1 -d' '` -n firefly -- /usr/bin/mysqldump -u root --password=Rey-1176 fireflyiii > $new_name

message="Backup stored "$today

sudo -u creylopez cat $new_name | mail -s "FireflyIII backup finished" "creylopez@yahoo.es"

#sudo rm $new_name
