Skip to content

Instantly share code, notes, and snippets.

@renekreijveld
Created March 20, 2014 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save renekreijveld/9664367 to your computer and use it in GitHub Desktop.
Save renekreijveld/9664367 to your computer and use it in GitHub Desktop.
#!/bin/sh
# jrestore - Restore a local site backup
#
# Copyright 2014 Rene Kreijveld - email@renekreijveld.nl
#
# This program is free software; you may redistribute it and/or modify it.
# General variables
VERSION=1.0
STOREPATH=/backups/sites
# Determine path of script
MYPATH=$( cd $(dirname $0) ; pwd -P )
# Include general functions
. ${MYPATH}/joomlafunctions
echo -e "\njrestore verion ${VERSION}, written by René Kreijveld\n"
echo "This is a Joomla! $versr.$versd site. Starting backup restore."
echo -e "The following backups were found (most recent backup is listed first):\n"
ls -1t ${STOREPATH}/${sitename}.*
echo -e "\nRestore which backup (copy/paste filename), or press Ctrl-C to abort?\n"
read -p "Filename: " restorefile
echo -e "\nUnpacking backup $restorefile"
tar xzf $restorefile
echo "Restoring database backup $database.sql"
if mysql --host=$host --user=$dbuser --password=$password --socket=$MYSOCK $database < $database.sql
then
echo "Database backup $database.sql restored."
rm $database.sql
echo -e "\nRestore backup website $sitenameclean completed."
exit 0
else
echo "Error restoring Database backup $database.sql!"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment