Advertisement
danielcristho

backup_metrics.sh

Mar 24th, 2024 (edited)
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.42 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. LOG_DIR="/home/{user}/metrics"
  4. BACKUP_DIR="/home/{user}/backups"
  5.  
  6. mkdir -p "$BACKUP_DIR"
  7.  
  8. DATE=$(date "+%Y%m%d%H")
  9.  
  10. BACKUP_FILE="backup_metrics_${DATE}.tar.gz"
  11.  
  12. tar -cf "${BACKUP_DIR}/${BACKUP_FILE}" "${LOG_DIR}/metrics_agg_"*.log
  13.  
  14. gzip "${BACKUP_DIR}/${BACKUP_FILE}"
  15.  
  16. rm -f "${LOG_DIR}/metrics_agg_"*.log
  17. ## chmod u+x ./backup_metrics.sh
  18. ## cronjob: 59 23 * * * bash /home/{user}/backup_metrics.sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement