Skip to content

Commit

Permalink
[backup]: better error handling in run_backup script (#124)
Browse files Browse the repository at this point in the history
Signed-off-by: Shikhar Soni <[email protected]>
  • Loading branch information
shikharish committed Feb 8, 2024
1 parent 3a9a07e commit 1a8f589
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions backup/run_backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ set -a
source .env
set +a

if [ -z "$MYSQL_PASSWORD" ]; then
echo "Missing MYSQL_PASSWORD env var"
exit 1
fi

timestamp=$(date +%Y_%m_%d_%H_%M_%S)

# Wiki paths
Expand All @@ -29,16 +34,11 @@ mkdir -p "${backups_path}/${backup_dir}"
echo -e '$wgReadOnly = "Automatic backup in progress; access will be restored in a few seconds.";' >>"$settings_file"

# Take a mysql dump
if [ -z "$MYSQL_PASSWORD" ]; then
echo "Missing MYSQL_PASSWORD env var"
exit 1
else
mysqldump --no-tablespaces \
mysqldump --no-tablespaces \
-h mysql-docker \
-u metakgp_user \
-p"$MYSQL_PASSWORD" \
metakgp_wiki_db >"${backups_path}/${backup_dir}/metakgp_wiki_db.sql"
fi

# Remove the notice and make the wiki editable
sed -i '$ d' "$settings_file"
Expand Down

0 comments on commit 1a8f589

Please sign in to comment.