# 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

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

#sudo docker exec `sudo docker container ls | grep mysql_mediawiki | cut -f1 -d' '` /usr/bin/mysqldump -u root --password=Dsa-0213 mediawiki > $new_name
sudo kubectl --kubeconfig /home/creylopez/.kube/config exec `kubectl --kubeconfig /home/creylopez/.kube/config get pod -n mediawiki|grep mysql|cut -f1 -d' '` -n mediawiki -- /usr/bin/mysqldump -u root --password=Dsa-0213 mediawiki > $new_name

message="Backup stored "$today

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

sudo rm $new_name
