Advertisement
sergio_educacionit

backup.sh

Sep 11th, 2024 (edited)
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3.  
  4. timestamp=$(date +%Y-%m-%d-%s)
  5.  
  6. # Eliminar ficheros de mas de 10 dias de antiguedad
  7. find /var/backups/mariadb -type f -mtime +10 -exec rm {} \;
  8.  
  9. # Volcado de bases de datos
  10. mysqldump --all-databases > /var/backups/mariadb/${timestamp}_all-databases.msql
  11.  
  12.  
  13. # compresion
  14. gzip /var/backups/mariadb/${timestamp}_all-databases.msql
  15.  
  16. # Firmado
  17. gpg2 --detach-sign \
  18. --output /var/backups/mariadb/${timestamp}_all-databases.msql.gz.sig \
  19. /var/backups/mariadb/${timestamp}_all-databases.msql.gz
  20.  
  21.  
  22. # Backup
  23. rsync -av \
  24. -e "ssh -i /root/.ssh/id_rsa" \
  25. /var/backups/mariadb/ \
  26. backupusr@192.168.0.94:/var/backups/mariadb-$HOSTNAME
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement