From 577ac7fe4860ab39fa5600a3df181a6fdb001471 Mon Sep 17 00:00:00 2001 From: Celestino Rey Date: Fri, 17 Oct 2025 08:03:27 +0200 Subject: [PATCH] Cambio en las shells de backups --- Forgejo/010-deployment.yaml | 2 +- HelmCharts/firefly-chart/templates/copyDBK8S | 24 +++++++++++ shells/copyFinanzas | 24 +++++++++++ shells/copyReyMotaApps | 45 ++++++++++++++++++++ shells/guardaJson.sh | 24 +++++------ terminaNS.sh | 2 + 6 files changed, 108 insertions(+), 13 deletions(-) create mode 100755 HelmCharts/firefly-chart/templates/copyDBK8S create mode 100755 shells/copyFinanzas create mode 100755 shells/copyReyMotaApps create mode 100644 terminaNS.sh diff --git a/Forgejo/010-deployment.yaml b/Forgejo/010-deployment.yaml index fd021d37..24a0e770 100644 --- a/Forgejo/010-deployment.yaml +++ b/Forgejo/010-deployment.yaml @@ -29,7 +29,7 @@ spec: spec: containers: - name: forgejo - image: codeberg.org/forgejo/forgejo:10 + image: codeberg.org/forgejo/forgejo:12.0.4 ports: - containerPort: 3000 name: forgejo diff --git a/HelmCharts/firefly-chart/templates/copyDBK8S b/HelmCharts/firefly-chart/templates/copyDBK8S new file mode 100755 index 00000000..1c250a6e --- /dev/null +++ b/HelmCharts/firefly-chart/templates/copyDBK8S @@ -0,0 +1,24 @@ +# 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 --column-statistics=0 -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 diff --git a/shells/copyFinanzas b/shells/copyFinanzas new file mode 100755 index 00000000..2a86bb84 --- /dev/null +++ b/shells/copyFinanzas @@ -0,0 +1,24 @@ +# 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 + +new_name=$BACKUP_FOLDER/Finanzas-$today.json + +ping -c 4 finanzas.reymota.es + +#curl https://finanzas.reymota.es/api/datos/ > $new_name +curl http://finanzas-finanzas.apps.ocp-cluster.reymota.lab/api/datos/ > $new_name + +message="Backup stored "$today + +sudo -u creylopez echo "Finanzas backup adjunto" |mail -s "Backup de Finanzas" creylopez@yahoo.es -A $new_name + +sudo rm $new_name diff --git a/shells/copyReyMotaApps b/shells/copyReyMotaApps new file mode 100755 index 00000000..a25eb976 --- /dev/null +++ b/shells/copyReyMotaApps @@ -0,0 +1,45 @@ +# 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_reymota +new_name=$file_name-$today.sql + +artistas=$BACKUP_FOLDER/artistas-$today.json +albumes=$BACKUP_FOLDER/albumes-$today.json +canciones=$BACKUP_FOLDER/canciones-$today.json + +vehiculos=$BACKUP_FOLDER/vehiculos-$today.json +repostajes=$BACKUP_FOLDER/repostajes-$today.json + +curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/lyrics/api/artistas/ > $artistas +curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/lyrics/api/albumes/ > $albumes +curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/lyrics/api/canciones/ > $canciones + +curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/repostajes/api/vehiculos/ > $vehiculos +curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/repostajes/api/repostajes/ > $repostajes + +zip $BACKUP_FOLDER/reymota-$today.zip $artistas $albumes $canciones $vehiculos $repostajes + +#kubectl --kubeconfig /home/creylopez/.kube/kubeconfig-okd -n reymota exec -ti deployment.apps/db -- /usr/lib/postgresql/15/bin/pg_dump --username=creylopez --dbname=reymota > $new_name + +message="Backup stored "$today + +#sudo -u creylopez cat $new_name | mail -s "ReyMotaApps backup finished" "creylopez@yahoo.es" +sudo -u creylopez echo "Reymota backup adjunto" |mail -s "Backup de Reymota" creylopez@yahoo.es -A $BACKUP_FOLDER/reymota-$today.zip + +#sudo rm $new_name +rm $BACKUP_FOLDER/artista* +rm $BACKUP_FOLDER/albumes* +rm $BACKUP_FOLDER/canciones* +rm $BACKUP_FOLDER/vehiculos* +rm $BACKUP_FOLDER/repostajes* + diff --git a/shells/guardaJson.sh b/shells/guardaJson.sh index ca6c78d4..68cf7e88 100755 --- a/shells/guardaJson.sh +++ b/shells/guardaJson.sh @@ -8,12 +8,12 @@ BACKUP_FOLDER=/tmp # Jugaralpadel -curl https://jugaralpadel.es/usuarios/api/usuarios/ > $BACKUP_FOLDER/jugar-usuarios.json -curl https://jugaralpadel.es/eventos/api/eventos/ > $BACKUP_FOLDER/jugar-eventos.json -curl https://jugaralpadel.es/eventos/api/reservas/ > $BACKUP_FOLDER/jugar-reservas.json -curl https://jugaralpadel.es/eventos/api/listaespera/ > $BACKUP_FOLDER/jugar-listaespera.json -curl https://jugaralpadel.es/eventos/api/noticias/ > $BACKUP_FOLDER/jugar-noticias.json -curl https://jugaralpadel.es/api/ayuda/ > $BACKUP_FOLDER/jugar-ayuda.json +curl http://jugaralpadel-jugaralpadel.apps.ocp-cluster.reymota.lab/usuarios/api/usuarios/ > $BACKUP_FOLDER/jugar-usuarios.json +curl http://jugaralpadel-jugaralpadel.apps.ocp-cluster.reymota.lab/eventos/api/eventos/ > $BACKUP_FOLDER/jugar-eventos.json +curl http://jugaralpadel-jugaralpadel.apps.ocp-cluster.reymota.lab/eventos/api/reservas/ > $BACKUP_FOLDER/jugar-reservas.json +curl http://jugaralpadel-jugaralpadel.apps.ocp-cluster.reymota.lab/eventos/api/listaespera/ > $BACKUP_FOLDER/jugar-listaespera.json +curl http://jugaralpadel-jugaralpadel.apps.ocp-cluster.reymota.lab/eventos/api/noticias/ > $BACKUP_FOLDER/jugar-noticias.json +curl http://jugaralpadel-jugaralpadel.apps.ocp-cluster.reymota.lab/api/ayuda/ > $BACKUP_FOLDER/jugar-ayuda.json tar cvfz $BACKUP_FOLDER/jugaralpadel-json.tar.gz $BACKUP_FOLDER/*.json sudo rm $BACKUP_FOLDER/*.json @@ -24,14 +24,14 @@ sudo rm $BACKUP_FOLDER/jugaralpadel-json.tar.gz # Reymota -curl https://reymota.es/usuarios/api/usuarios/ > $BACKUP_FOLDER/reymota-usuarios.json +curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/usuarios/api/usuarios/ > $BACKUP_FOLDER/reymota-usuarios.json -curl https://reymota.es/lyrics/api/artistas/ > $BACKUP_FOLDER/reymota-artistas.json -curl https://reymota.es/lyrics/api/albumes/ > $BACKUP_FOLDER/reymota-albumes.json -curl https://reymota.es/lyrics/api/canciones/ > $BACKUP_FOLDER/reymota-canciones.json +curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/lyrics/api/artistas/ > $BACKUP_FOLDER/reymota-artistas.json +curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/lyrics/api/albumes/ > $BACKUP_FOLDER/reymota-albumes.json +curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/lyrics/api/canciones/ > $BACKUP_FOLDER/reymota-canciones.json -curl https://reymota.es/repostajes/api/vehiculos/ > $BACKUP_FOLDER/reymota-vehiculos.json -curl https://reymota.es/repostajes/api/repostajes/ > $BACKUP_FOLDER/reymota-repostajes.json +curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/repostajes/api/vehiculos/ > $BACKUP_FOLDER/reymota-vehiculos.json +curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/repostajes/api/repostajes/ > $BACKUP_FOLDER/reymota-repostajes.json tar cvfz $BACKUP_FOLDER/reymota-json.tar.gz $BACKUP_FOLDER/*.json sudo rm $BACKUP_FOLDER/*.json diff --git a/terminaNS.sh b/terminaNS.sh new file mode 100644 index 00000000..a2fe2525 --- /dev/null +++ b/terminaNS.sh @@ -0,0 +1,2 @@ +NS=`kubectl get ns |grep Terminating | awk 'NR==1 {print $1}'` && kubectl get namespace "$NS" -o json | tr -d "\n" | sed "s/\"finalizers\": \[[^]]\+\]/\"finalizers\": []/" | kubectl replace --raw /api/v1/namespaces/$NS/finalize -f - +