Advertisement
Guest User

Untitled

a guest
Jun 16th, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. set -e
  3.  
  4. # Configure these as needed
  5. DIRECTORY="/opt/gst-deploye/"
  6. ARCHIVE_PATH="/home/usradmin/archived.gst.rollout/gst_fullbackup/"
  7. DATE=$(date +"%d.%m.%Y_%H%M")
  8. ARCHIVE_FILE="$(hostname)_$DATE.tgz"
  9. HOST='192.168.6.73'
  10. USER='admin'
  11. PASS='admin'
  12. TARGETFOLDER='/gst/gst_fullbackup/'
  13. SOURCEFOLDER='/home/usradmin/archived.gst.rollout/gst_fullbackup/'
  14.  
  15. #'/gst/gst_folderbackup/'
  16.  
  17.  
  18.  
  19. # Create the tarball
  20. archive_directory () {
  21. tar czf $ARCHIVE_PATH/$ARCHIVE_FILE $DIRECTORY &> /dev/null
  22. }
  23.  
  24. # Delete files older than 7 days
  25. cleanup_old_files() {
  26. find $ARCHIVE_PATH -mtime +4 -exec rm {} \;
  27. }
  28.  
  29.  
  30. upload_backup_fullbackup_files(){
  31. lftp -f"
  32. open $HOST
  33. user $USER $PASS
  34. lcd $SOURCEFOLDER
  35. # mirror - mirror folder contents --reverse is to put file -n put files which are new --verbose print details source folder target folder
  36. mirror --reverse --continue -n --verbose $SOURCEFOLDER $TARGETFOLDER
  37. bye
  38. "
  39. }
  40.  
  41. # Do the stuff with the things
  42. archive_directory
  43. cleanup_old_files
  44. upload_backup_fullbackup_files
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement