From cdf2c8db14faa53918d37166726cca851c51e89d Mon Sep 17 00:00:00 2001 From: raphanaud Date: Fri, 8 Oct 2021 15:45:28 +0200 Subject: [PATCH] script --- sio2/sisr/35-script/bash/script/restoration | 17 +++++++++++++++++ sio2/sisr/35-script/bash/script/sauv | 15 +++++++++++++++ 2 files changed, 32 insertions(+) create mode 100755 sio2/sisr/35-script/bash/script/restoration create mode 100755 sio2/sisr/35-script/bash/script/sauv diff --git a/sio2/sisr/35-script/bash/script/restoration b/sio2/sisr/35-script/bash/script/restoration new file mode 100755 index 0000000..5f9c727 --- /dev/null +++ b/sio2/sisr/35-script/bash/script/restoration @@ -0,0 +1,17 @@ +#!/bin/bash +DAT=$(date "+%u") +DEST=/home/sv/d/"${DAT}" +HOST=root@192.168.0.29 +ssh "${HOST}" apt install -y rsync apache2 mariadb-server php +ssh "${HOST}" "mysql CREATE DATABASES wordpress;" #a refaire +ssh "${HOST}" "mysql -u wordpress_user -pqdrhh45 wordpress < "${DEST}"/wordpress.sql" #a refaire +scp -r "${DEST}"/wordpress "${HOST}":/var/www/html/ +scp "${DEST}"/default-ssl.conf "${HOST}":/etc/apache2/sites-available/ +scp "${DEST}"/wordpress.conf "${HOST}":/etc/apache2/sites-available/ +scp "${DEST}"/server.key "${HOST}":/etc/apache2/ +scp "${DEST}"/server.crt "${HOST}":/etc/apache2/ +#rsync -az "${DEST}"/wordpress "${HOST}":/var/www/html/ +#rsync -az "${DEST}"/default-ssl.conf "${HOST}":/etc/apache2/sites-available/ +#rsync -az "${DEST}"/wordpress.conf "${HOST}":/etc/apache2/sites-available/ +#rsync -az "${DEST}"/server.key "${HOST}":/etc/apache2/ +#rsync -az "${DEST}"/server.crt "${HOST}":/etc/apache2/ diff --git a/sio2/sisr/35-script/bash/script/sauv b/sio2/sisr/35-script/bash/script/sauv new file mode 100755 index 0000000..f16a3a0 --- /dev/null +++ b/sio2/sisr/35-script/bash/script/sauv @@ -0,0 +1,15 @@ +#!/bin/bash +DAT=$(date "+%u") +DEST=/home/sv +DEST2="${DEST}/d/${DAT}" +[ -d "${DEST}/d" ] || mkdir -p "${DEST}/d" +[ -d "${DEST}/d/${DAT}" ] || mkdir -p "${DEST}/d/${DAT}" +HOST=sauv@192.168.0.34 +ssh "${HOST}" "mysqldump -u wordpress_user -pqdrhh45 wordpress|gzip -" >"${DEST2}"/wordpress.sql.gz + +rsync -av -e ssh "${HOST}":/var/www/html/wordpress "${DEST2}" +rsync -av -e ssh "${HOST}":/etc/apache2/sites-available/default-ssl.conf "${DEST2}"/default-ssl.conf +rsync -av -e ssh "${HOST}":/etc/apache2/sites-available/wordpress.conf "${DEST2}"/wordpress.conf +rsync -av -e ssh "${HOST}":/etc/apache2/server.key "${DEST2}"/server.key +rsync -av -e ssh "${HOST}":/etc/apache2/server.crt "${DEST2}"/server.crt +