carloxp
10/12/2018 - 8:25 PM

Create a full backup of a Joomla website to tar gzip file and store in backup directory

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}