première version finale de import backup
This commit is contained in:
parent
7dc9ba3624
commit
448a173b4f
|
|
@ -17,16 +17,29 @@ if [[ "$answer" == "y" ]]; then
|
||||||
username=$(getent passwd 1001 | cut -d: -f1)
|
username=$(getent passwd 1001 | cut -d: -f1)
|
||||||
|
|
||||||
echo -e "${PURPLE}${BOLD}Did you import a .tar.gz backup in /home/${username} ? (y/N) ${RESET}"
|
echo -e "${PURPLE}${BOLD}Did you import a .tar.gz backup in /home/${username} ? (y/N) ${RESET}"
|
||||||
|
read answer
|
||||||
if [[ "$answer" == "y" ]]; then
|
if [[ "$answer" == "y" ]]; then
|
||||||
|
|
||||||
site_name=$(ls /var/www/repositories/ | grep -v '^cms')
|
site_name=$(ls /var/www/repositories/ | grep -v '^cms')
|
||||||
backup_archive=$(ls "/home/${username}/${site_name}_export*")
|
backup_archive=$(ls "/home/${username}/${site_name}_export"*)
|
||||||
|
|
||||||
tar -xzvf $backup_archive -C "/home/${username}"
|
tar -xzvf $backup_archive -C "/home/${username}"
|
||||||
|
|
||||||
|
rm $backup_archive
|
||||||
|
|
||||||
|
backup_directory=$(ls "/home/${username}/${site_name}_export"*)
|
||||||
|
db_export=$(ls "${backup_directory}/db"*)
|
||||||
|
|
||||||
db_password=$(cat /var/www/repositories/cms*/.env | grep DB_PASSWORD | sed "s/[^']*'\([^']*\)'.*/\1/")
|
db_password=$(cat /var/www/repositories/cms*/.env | grep DB_PASSWORD | sed "s/[^']*'\([^']*\)'.*/\1/")
|
||||||
|
|
||||||
|
mariadb -u directus "-p${db_password}" -e "DROP DATABASE IF EXISTS directus; CREATE DATABASE directus;"
|
||||||
|
mariadb -u directus "-p${db_password}" directus < $db_export
|
||||||
|
|
||||||
|
cms_directory=$(ls /var/www/repository/cms*)
|
||||||
|
|
||||||
|
mv -f "${backup_directory}/uploads" $cms_directory
|
||||||
|
|
||||||
|
rm -r backup_directory
|
||||||
else
|
else
|
||||||
echo -e "${PURPLE}${BOLD}Please import a .tar.gz backup in /home/${username}${RESET}"
|
echo -e "${PURPLE}${BOLD}Please import a .tar.gz backup in /home/${username}${RESET}"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue