Advertisement
mikelieman

Untitled

Feb 13th, 2016
310
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.64 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. #  Sticking:
  4. #   backup.sh >> logfile.txt 2>&1
  5. #
  6. #    into your crontab should take care of this.  
  7.  
  8. ##############################################################################################
  9. #  Things to backup and their mountpoints
  10. ##############################################################################################
  11.  
  12. # Backups Directory
  13. BACKUPS_DIR="/storage/backups/server"
  14.                                                                                                                                                                                        
  15. SOURCES="./etc ./home ./opt ./root ./storage ./var/log"
  16.  
  17. ##############################################################################################
  18. #  Begin
  19. ##############################################################################################
  20.  
  21. TS=`date +'%Y-%m-%d-%H%M%S'`
  22. HOSTNAME=`hostname`
  23. TARNAME="${BACKUPS_DIR}/${HOSTNAME}-${TS}.tar.bz2"
  24. STARTTIME=`date`
  25.  
  26. echo -e "\n\n--------------------------------------------------------------------------------"
  27. echo -e "\n$STARTTIME: Running $0"
  28. echo -e "\n$STARTTIME: Beginning backup of server:"
  29. echo "    Backup up directories: $SOURCES"
  30. echo "    to: $TARNAME"
  31. echo
  32. echo
  33. echo "----  Beginning Backup Operation  ---"
  34. date
  35. cd /
  36. tar cjf "${TARNAME}" --exclude=.${BACKUPS_DIR} ${SOURCES}
  37. cd -
  38. /root/bin/clean_old_files.pl ${BACKUPS_DIR}
  39. echo
  40. echo "----  Ending Backup Operation  ---"
  41. date
  42.  
  43. ##############################################################################################
  44. #  __END__
  45. ##############################################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement