Skip to content

Instantly share code, notes, and snippets.

@lrkwz
Created September 15, 2011 08:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lrkwz/1218821 to your computer and use it in GitHub Desktop.
Save lrkwz/1218821 to your computer and use it in GitHub Desktop.
Safe backup liferay.
#!/bin/bash
DBUSR=****
DBPWD=****
# You should be root
if [ "$(whoami)" != "root" ]; then
echo "Sorry, you are not root."
exit 1
fi
DATE=$(date "+%F.%R")
### Stop Tomcat
/opt/liferay-portal-6.0.5/tomcat-6.0.26/bin/shutdown.sh
echo "Waiting for shutdown to complete..."
while [ "x" = "x" ]
do
netstat -an | grep 8080 | grep LISTEN 1> /dev/null 2>&1
if [ "$?" -ne "0" ]
then
break
else
echo "... still waiting"
sleep 1
fi
done
rm -Rf /opt/liferay-portal-6.0.5/tomcat-6.0.26/temp/*
rm -Rf /opt/liferay-portal-6.0.5/tomcat-6.0.26/work/*
rm -Rf /opt/liferay-portal-6.0.5/tomcat-6.0.26/logs/*
### Copy files
rsync -rav /opt/liferay-portal-6.0.5/ /opt/liferay-portal-CLONE/
### Dump DB
mysqldump --opt -u $DBUSR -p$DBPWD --databases lportal lportal_dev > lportal_$DATE.sql
/opt/liferay-portal-6.0.5/tomcat-6.0.26/bin/startup.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment