Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backup-fix #160

Merged
merged 5 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ embark_db/
www/
.venv/
safe/
.embark_db_backup

# other stuff
*.zip
Expand Down
19 changes: 2 additions & 17 deletions export-DB.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,5 @@ fi
echo "USER is ${SUDO_USER:-${USER}}"

import_helper

# WSL/OS version check
# WSL support - currently experimental!
if grep -q -i wsl /proc/version; then
echo -e "\n${ORANGE}INFO: System running in WSL environment!$NC"
echo -e "\n${ORANGE}INFO: WSL is currently experimental!$NC"
WSL=1
fi

if [[ "$WSL" -eq 1 ]]; then
check_docker_wsl
fi

# read .env file
export "$(grep -v '^#' .env | xargs)"

docker-compose exec -T --privileged --user root embark_db mysqldump --user="$DATABASE_USER" --password="$DATABASE_PASSWORD" "$DATABASE_NAME" --no-tablespaces > full-backup-"$(date +%F)".sql
cp -urvi ./embark_db ./.embark_db_backup
tar -cf full-backup-"$(date +%F)".tar ./.embark_db_backup
36 changes: 13 additions & 23 deletions import-DB.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,16 @@ import_helper()
echo -e "\\n""==> ""$GREEN""Imported ""$HELPER_COUNT"" necessary files""$NC\\n"
}

SQL_FILE="${1:-}"

if ! [[ -f "$SQL_FILE" ]]; then
echo -e "\\n$RED""No SQL-FILE supplied!""$NC\\n"
exit 1
ALT_BACKUP_FILE="${1:-}"
export BACKUP_FILE=""
if [[ -n "${ALT_BACKUP_FILE}" ]]; then
if ! [[ -f "${ALT_BACKUP_FILE}" ]]; then
echo -e "\\n$RED""Error with input for BACKUP FILE!""$NC\\n"
exit 1
fi
BACKUP_FILE="${ALT_BACKUP_FILE}"
else
BACKUP_FILE="$(find . -type f -iname "full-backup-*.tar" | sort -n | tail -n 1)"
fi

cd "$(dirname "$0")" || exit 1
Expand All @@ -56,25 +61,10 @@ echo "USER is ${SUDO_USER:-${USER}}"

import_helper

# WSL/OS version check
# WSL support - currently experimental!
if grep -q -i wsl /proc/version; then
echo -e "\n${ORANGE}INFO: System running in WSL environment!$NC"
echo -e "\n${ORANGE}INFO: WSL is currently experimental!$NC"
WSL=1
fi

if [[ "$WSL" -eq 1 ]]; then
check_docker_wsl
fi

# read .env file
export "$(grep -v '^#' .env | xargs)"

docker-compose -f ./docker-compose.yml up -d
tar -xf "${BACKUP_FILE}"

echo "$SQL_FILE"
rsync -a --progress ./.embark_db_backup/ ./embark_db/

docker-compose exec -T --privileged --user root embark_db mysql --user="$DATABASE_USER" --password="$DATABASE_PASSWORD" "$DATABASE_NAME" < "$SQL_FILE"
rm -rf ./.embark_db_backup/

echo -e "\\n""==> ""$GREEN""Import successful""$NC"
5 changes: 4 additions & 1 deletion installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ uninstall (){
if [[ -d ./static ]]; then
rm -Rv ./static
fi
if [[ -d ./embark/static/external ]]; then
rm -Rv ./embark/static/external
fi
if [[ -d ./cert ]]; then
rm -Rv ./cert
fi
Expand Down Expand Up @@ -511,7 +514,7 @@ uninstall (){
# delete .env
echo -e "$ORANGE""$BOLD""Delete env""$NC"
if [[ -f ./.env ]]; then
rm ./.env
rm -Rvf ./.env
fi

# delete shared volumes and migrations
Expand Down
Loading