From Morose Moth, 3 Weeks ago, written in Plain Text.
  1. !/bin/bash                                                        
  2.  
  3. # name for backup file created
  4. FILENAME=backup-$(date +%-Y%-m%-d)-$(date +%T).tgz
  5.  
  6. # user defines directory to backup (aka: source path)  
  7. echo "Path of directory to backup?"
  8.  
  9. # path to directory variable
  10. read -r SRCDIR
  11.  
  12. # user defines backup destination
  13. echo "Where would you like the backup saved?"
  14.  
  15. # get backup destination variable
  16. read -r DESTDIR
  17.  
  18.  
  19. # verify before committing to backup operation
  20. while true;
  21. do
  22.         read -rp "Backup?: $SRCDIR " yn
  23.         case $yn in
  24.         [Yy]* ) tar czf "$FILENAME" "$SRCDIR" "$DESTDIR";;            
  25.         [Nn]* ) exit;;
  26.         * ) echo "Please answer yes or no.";;
  27.         esac
  28. done
  29. echo "Backup Complete"
  30. exit 0    
  31.  
  32.  
captcha