update script to use vhost-exp.sh
This commit is contained in:
parent
09ec06aee4
commit
a94f38f1c1
|
@ -35,64 +35,16 @@ else
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d /srv/www/$domain/.archive/ ]]; then
|
# create export of vhost settings
|
||||||
echo "/srv/www/$domain/.archive/ already exists."
|
/usr/local/bin/vhost-exp.sh -d $domain
|
||||||
echo "Remove /srv/www/$domain/.archive/ and run again if desired."
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
mkdir /srv/www/$domain/.archive/
|
|
||||||
fi
|
|
||||||
|
|
||||||
cp --archive --parents /home/$username /srv/www/$domain/.archive/
|
# copy user home dir
|
||||||
|
cp --archive --parents /home/$username /srv/www/$domain/.exp/
|
||||||
# apache config
|
|
||||||
if [[ -f /etc/apache2/sites-available/$domain.conf ]]; then
|
|
||||||
cp --archive --parents /etc/apache2/sites-*/$domain.conf /srv/www/$domain/.archive/
|
|
||||||
fi
|
|
||||||
|
|
||||||
# letsencrypt certificate
|
|
||||||
if [[ -f /etc/letsencrypt/renewal/$domain.conf ]]; then
|
|
||||||
cp --archive --parents /etc/letsencrypt/archive/$domain/ /srv/www/$domain/.archive/
|
|
||||||
cp --archive --parents /etc/letsencrypt/live/$domain/ /srv/www/$domain/.archive/
|
|
||||||
cp --archive --parents /etc/letsencrypt/renewal/$domain.conf /srv/www/$domain/.archive/
|
|
||||||
fi
|
|
||||||
|
|
||||||
# letsencrypt pem file
|
|
||||||
if [[ -f /etc/ssl/letsencrypt/$domain.pem ]]; then
|
|
||||||
cp --archive --parents /etc/ssl/letsencrypt/$domain.pem /srv/www/$domain/.archive/
|
|
||||||
fi
|
|
||||||
|
|
||||||
# varnish config
|
|
||||||
if [[ -f /etc/varnish/sites.d/$domain.vcl ]]; then
|
|
||||||
cp --archive --parents /etc/varnish/sites.d/$domain.vcl /srv/www/$domain/.archive/
|
|
||||||
fi
|
|
||||||
|
|
||||||
# php-fpm
|
|
||||||
vhost::set-phpVersion
|
|
||||||
if [[ -f /etc/php/$phpVersion/fpm/pool.d/$username.conf ]]; then
|
|
||||||
cp --archive --parents /etc/php/$phpVersion/fpm/pool.d/$username.conf /srv/www/$domain/.archive/
|
|
||||||
fi
|
|
||||||
|
|
||||||
# mysql database(s)
|
|
||||||
basedatabase=${domain//./dot}
|
|
||||||
basedatabase=${basedatabase//-/dash}
|
|
||||||
|
|
||||||
database_array=(`mysql -s -N -e "SELECT SCHEMA_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '$basedatabase' OR SCHEMA_NAME LIKE '$basedatabase\_%'" | tr '\n' ' ' | xargs`)
|
|
||||||
|
|
||||||
if [[ ${#database_array[@]} -gt 0 ]]; then
|
|
||||||
|
|
||||||
mkdir /srv/www/$domain/.archive/mysql/
|
|
||||||
|
|
||||||
for database in "${database_array[@]}"; do
|
|
||||||
|
|
||||||
mysqldump --opt --quote-names --events --databases $database | gzip > /srv/www/$domain/.archive/mysql/$database.sql.gz
|
|
||||||
|
|
||||||
done
|
|
||||||
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
# make sure archive dir exists
|
||||||
if [[ ! -d /opt/archives ]]; then
|
if [[ ! -d /opt/archives ]]; then
|
||||||
mkdir /opt/archives
|
mkdir /opt/archives
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# create tarball
|
||||||
tar --directory=/srv/www/ -czf /opt/archives/$domain.tar.gz $domain
|
tar --directory=/srv/www/ -czf /opt/archives/$domain.tar.gz $domain
|
||||||
|
|
Loading…
Reference in New Issue
Block a user