From a94f38f1c14a783426ee777e1e8a433e160f8ecd Mon Sep 17 00:00:00 2001 From: Matthew Saunders Brown Date: Fri, 1 Sep 2023 15:33:08 -0700 Subject: [PATCH] update script to use vhost-exp.sh --- bin/vhost-archive.sh | 60 +++++--------------------------------------- 1 file changed, 6 insertions(+), 54 deletions(-) diff --git a/bin/vhost-archive.sh b/bin/vhost-archive.sh index f96e553..3316d6b 100755 --- a/bin/vhost-archive.sh +++ b/bin/vhost-archive.sh @@ -35,64 +35,16 @@ else exit 1 fi -if [[ -d /srv/www/$domain/.archive/ ]]; then - echo "/srv/www/$domain/.archive/ already exists." - echo "Remove /srv/www/$domain/.archive/ and run again if desired." - exit 1 -else - mkdir /srv/www/$domain/.archive/ -fi +# create export of vhost settings +/usr/local/bin/vhost-exp.sh -d $domain -cp --archive --parents /home/$username /srv/www/$domain/.archive/ - -# 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 +# copy user home dir +cp --archive --parents /home/$username /srv/www/$domain/.exp/ +# make sure archive dir exists if [[ ! -d /opt/archives ]]; then mkdir /opt/archives fi +# create tarball tar --directory=/srv/www/ -czf /opt/archives/$domain.tar.gz $domain