copyReyMotaApps 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. # Backup date
  2. today=$(date "+%Y_%m_%d-%H_%M_%S")
  3. echo "Current date: $today"
  4. # build up filename
  5. # destination folder (change to your own needs)
  6. BACKUP_FOLDER=/tmp
  7. file_name=$BACKUP_FOLDER/bkup_reymota
  8. new_name=$file_name-$today.sql
  9. artistas=$BACKUP_FOLDER/artistas-$today.json
  10. albumes=$BACKUP_FOLDER/albumes-$today.json
  11. canciones=$BACKUP_FOLDER/canciones-$today.json
  12. vehiculos=$BACKUP_FOLDER/vehiculos-$today.json
  13. repostajes=$BACKUP_FOLDER/repostajes-$today.json
  14. curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/lyrics/api/artistas/ > $artistas
  15. curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/lyrics/api/albumes/ > $albumes
  16. curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/lyrics/api/canciones/ > $canciones
  17. curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/repostajes/api/vehiculos/ > $vehiculos
  18. curl http://reymota-reymota.apps.ocp-cluster.reymota.lab/repostajes/api/repostajes/ > $repostajes
  19. zip $BACKUP_FOLDER/reymota-$today.zip $artistas $albumes $canciones $vehiculos $repostajes
  20. #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
  21. message="Backup stored "$today
  22. #sudo -u creylopez cat $new_name | mail -s "ReyMotaApps backup finished" "creylopez@yahoo.es"
  23. sudo -u creylopez echo "Reymota backup adjunto" |mail -s "Backup de Reymota" creylopez@yahoo.es -A $BACKUP_FOLDER/reymota-$today.zip
  24. #sudo rm $new_name
  25. rm $BACKUP_FOLDER/artista*
  26. rm $BACKUP_FOLDER/albumes*
  27. rm $BACKUP_FOLDER/canciones*
  28. rm $BACKUP_FOLDER/vehiculos*
  29. rm $BACKUP_FOLDER/repostajes*