Skip to content

Instantly share code, notes, and snippets.

@renekreijveld
Created July 3, 2014 11:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save renekreijveld/4cbeae83c68711ca35b3 to your computer and use it in GitHub Desktop.
Save renekreijveld/4cbeae83c68711ca35b3 to your computer and use it in GitHub Desktop.
Create a full backup of a Joomla website to tar gzip file and store in backup directory
#!/bin/sh
# jbackupstore -- Create a full backup of a Joomla website to tar gzip file and store in backup directory
#
# Copyright 2012 Rene Kreijveld - email@renekreijveld.nl
#
# This program is free software; you may redistribute it and/or modify it.
#
# Warning! This script needs the file joomlafunctions. This has to be installed in the same directory as this script.
#
# Define general variables
NOW=$(date +"%Y%m%d-%H%M%S")
STOREPATH=/backups/sites
LOGFILE=/usr/local/sbin/sitesbackup.log
# Determine path of script
MYPATH=$( cd $(dirname $0) ; pwd -P )
# Include general functions
. ${MYPATH}/joomlafunctions
echo "`date` Start backup $sitename" >> ${LOGFILE}
# dump the database to a .sql file
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
# backup site
tar czf ${STOREPATH}/${sitename}.${NOW}.tgz .htaccess *
# cleanup datebase dump
rm $database.sql
echo "`date` End backup $sitename" >> ${LOGFILE}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment