Guest User

Untitled

a guest
Oct 12th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # jbackup -- Create a full backup (including database) of a Joomla website to .tgz file.
  4. # Supports Joomla 1.0 - 3.3
  5. #
  6. # Copyright 2014 Rene Kreijveld - email@renekreijveld.nl
  7. #
  8. # This program is free software; you may redistribute it and/or modify it.
  9. #
  10. # Warning! This script needs the file joomlafunctions. This has to be installed in the same directory as this script.
  11. #
  12.  
  13. # General variables
  14. VERSION=2.0
  15.  
  16. # Determine path of script
  17. MYPATH=$( cd $(dirname $0) ; pwd -P )
  18.  
  19. # display usage information
  20. usage() {
  21. echo "jbackup, written by Rene Kreijveld."
  22. echo " "
  23. echo "Usage: jbackup [-z] [-h]"
  24. echo " "
  25. echo "Default action is .tgz backup."
  26. echo "-z Zip. Backup to a zipfile instead of a tgzfile."
  27. echo "-h Help. Display this info."
  28. echo " "
  29. echo "Run jbackup at the root of your website, where the configuration.php is."
  30. echo " "
  31. exit 0
  32. }
  33.  
  34. # Default no zipfile
  35. zip="no"
  36.  
  37. # process the arguments
  38. while getopts zth opt; do
  39. case "$opt" in
  40. z) zip="yes";;
  41. h) usage;;
  42. \?) usage;;
  43. esac
  44. done
  45.  
  46. # Include general functions
  47. . ${MYPATH}/joomlafunctions
  48.  
  49. echo "jbackup verion ${VERSION}, written by René Kreijveld"
  50. echo "This is a Joomla! $versr.$versd site. Starting backup..."
  51.  
  52. # Dump the database to a .sql file
  53. echo "Creating database dump..."
  54. if mysqldump --skip-opt --add-drop-table --add-locks --create-options --disable-keys --lock-tables --quick --set-charset --host=$host --user=$dbuser --password=$password --socket=$MYSOCK $database > $database.sql; then
  55. echo "$database.sql created."
  56. else
  57. echo "Error creating database dump."
  58. exit 1
  59. fi
  60.  
  61. if [ -e .htaccess ]; then
  62. htaccess=".htaccess"
  63. else
  64. htaccess=""
  65. fi
  66.  
  67. # Create the backupfile
  68. if echo "$zip" | grep -q "no" ; then
  69. tar czf ${sitename}.tgz $htaccess *
  70. fi
  71.  
  72. if echo "$zip" | grep -q "yes" ; then
  73. zip -q -r ${sitename}.zip $htaccess *
  74. fi
  75.  
  76. # Cleanup datebase dump
  77. rm $database.sql
  78.  
  79. # End
  80. if echo "$zip" | grep -q "no" ; then
  81. echo "Your backup is ready in $sitename.tgz:"
  82. ls -l $sitename.tgz
  83. fi
  84.  
  85. if echo "$zip" | grep -q "yes" ; then
  86. echo "Your backup is ready in $sitename.zip:"
  87. ls -l $sitename.zip
  88. fi
Add Comment
Please, Sign In to add comment