Advertisement
jaimerosariojusticia

Ubuntu proxy backup script

Jul 12th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.37 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. #=============================================================================#
  4. # Proxy Backup Script
  5. #
  6. # by Jaime Rosario Justicia
  7. #=============================================================================#
  8. #
  9. #
  10. #
  11. #=============================================================================#
  12. # Variables
  13. #=============================================================================#
  14. day=$(date +%Y-%m-%d)
  15. ETC_DG=/etc/dansguardian
  16. TARGZ=proxy-backup-"$day".tgz
  17. #=============================================================================#
  18. # Files included for the backup
  19. #=============================================================================#
  20. include_files="/etc/apache2 /etc/bind /etc/cron.d/update-motd /etc/crontab $ETC_DG $ETC_DG/languages/ukenglish /etc/default/locale /etc/dhcpd/dhcpd.conf /etc/fstab /etc/group /etc/gshadow /etc/host.conf /etc/hostname /etc/hosts /etc/init.d /etc/iptables.up.rules /etc/krb5.conf /etc/localtime /etc/mime.types /etc/network/interfaces /etc/nsswitch.conf /etc/resolv.conf /etc/samba /etc/squid3 /etc/ssh /etc/syslog.conf /etc/timezone /usr/share/squid3/errors/templates/ /var/www"
  21. #=============================================================================#
  22. # Files excluded from the backup
  23. #=============================================================================#
  24. exclude_files=$(echo -e --exclude "'"*.20*"'" --exclude "$ETC_DG/authplugins" --exclude "$ETC_DG/contentscanners" --exclude "$ETC_DG/downloadmanagers" --exclude "$ETC_DG/languages/arspanish" --exclude "$ETC_DG/languages" --exclude "$ETC_DG/lists/blacklists" --exclude "$ETC_DG/lists/contentscanners" --exclude "$ETC_DG/lists/downloadmanagers" --exclude "$ETC_DG/lists/phraselists" --exclude "/home/$SUDO_USER/proxy-backup*" --exclude "/var/www/squid-reports" --exclude "'"*.tgz"'" )
  25. #=============================================================================#
  26. # Update and cleanup of IPTables and Dansguardian
  27. #=============================================================================#
  28. iptables-save > /etc/iptables.up.rules
  29. find "$ETC_DG" -name '*.20*' -execdir rm {} \;
  30. #=============================================================================#
  31. # Starts the backup
  32. #=============================================================================#
  33. tar cvfz /tmp/"$TARGZ" "$include_files" "$exclude_files"
  34. mv /tmp/"$TARGZ" /home/"$SUDO_USER"/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement