Advertisement
Guest User

Untitled

a guest
Aug 17th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.45 KB | None | 0 0
  1. #!/bin/sh
  2. ############################################################################
  3. # Local Vars
  4. wwwroot='/www';
  5. backupdir='/mnt/cymbackup';
  6. tempdir='tempback';
  7. backupname='cymsuite';
  8. dbuser='root';
  9. dbpass='g0l1ath';
  10. workdir="${wwwroot}/${tempdir}";
  11.  
  12. # Database Names
  13. db[0]='Ophelia';
  14. db[1]='Janus2';
  15. db[2]='Titan';
  16.  
  17. # Website Names
  18. dir[0]='Ophelia';
  19. dir[1]='Hydra';
  20. dir[2]='Oberon';
  21. dir[3]='Titan';
  22. dir[4]='Mimas2';
  23.  
  24. ############################################################################
  25. #  Backing up all the changing databases from array
  26. echo "";
  27. echo "Backing up databases";
  28. for element in $(seq 0 $((${#db[@]}-1)))
  29. do
  30.      echo "Dumping: ${db[$element]}";
  31.      outdir="${workdir}/${db[$element]}.sql";
  32.      mysqldump -u $dbuser -p$dbpass ${db[$element]} > $outdir;
  33.      gzip $outdir;
  34. done
  35.  
  36.  
  37. ############################################################################
  38. #  Backing up all the changing websites from array
  39. echo "";
  40. echo "Backing up working directories";
  41. for element in $(seq 0 $((${#dir[@]}-1)))
  42. do
  43.      tar -C $wwwroot -czf $workdir/${dir[$element]}.tgz ${dir[$element]};
  44.      echo ${dir[$element]};
  45. done
  46.  
  47.  
  48. ############################################################################
  49. # Moving the backup to backup server
  50. echo "";
  51. echo "Condensing into one archive and copying it to backup dir ${backupdir}";
  52. tar -C $wwwroot -czf ${backupdir}/${backupname}.tgz $tempdir;
  53.  
  54. echo "";
  55. echo "Process completed";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement