-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Add Backup/restore scripts #2029
Merged
Merged
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
cmd=backup | ||
source utilities/set-up-error-reporting-for-scripts.sh | ||
source utilities/helpers.sh | ||
$cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#!/usr/bin/env bash | ||
log_name=clean | ||
cmd=clean | ||
|
||
source utilities/set-up-error-reporting-for-scripts.sh | ||
source utilities/docker-cleanup.sh | ||
source utilities/helpers.sh | ||
$cmd |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#!/usr/bin/env bash | ||
|
||
# The purpose of this script is to make it easy to reset a local self-hosted | ||
# install to a clean state, optionally targeting a particular version. | ||
|
||
if [ -n "${DEBUG:-}" ]; then | ||
set -x | ||
fi | ||
|
||
function confirm() { | ||
read -p "$1 [y/n] " confirmation | ||
if [ "$confirmation" != "y" ]; then | ||
echo "Canceled. 😅" | ||
exit | ||
fi | ||
} | ||
|
||
function clean() { | ||
# If we have a version given, validate it. | ||
# ---------------------------------------- | ||
# Note that arbitrary git refs won't work, because the *_IMAGE variables in | ||
# .env will almost certainly point to :latest. Tagged releases are generally | ||
# the only refs where these component versions are pinned, so enforce that | ||
# we're targeting a valid tag here. Do this early in order to fail fast. | ||
if [ -n "$version" ]; then | ||
set +e | ||
git rev-parse --verify --quiet "refs/tags/$version" >/dev/null | ||
if [ $? -gt 0 ]; then | ||
echo "Bad version: $version" | ||
exit | ||
fi | ||
set -e | ||
fi | ||
|
||
false "noooo" | ||
|
||
# Make sure they mean it. | ||
if [ "${FORCE_CLEAN:-}" == "1" ]; then | ||
echo "☠️ Seeing FORCE=1, forcing cleanup." | ||
echo | ||
else | ||
confirm "☠️ Warning! 😳 This is highly destructive! 😱 Are you sure you wish to proceed?" | ||
echo "Okay ... good luck! 😰" | ||
fi | ||
|
||
# Hit the reset button. | ||
$dc down --volumes --remove-orphans --rmi local | ||
|
||
# Remove any remaining (likely external) volumes with name matching 'sentry-.*'. | ||
for volume in $(docker volume list --format '{{ .Name }}' | grep '^sentry-'); do | ||
docker volume remove $volume >/dev/null && | ||
echo "Removed volume: $volume" || | ||
echo "Skipped volume: $volume" | ||
done | ||
|
||
# If we have a version given, switch to it. | ||
if [ -n "$version" ]; then | ||
git checkout "$version" | ||
fi | ||
} | ||
|
||
function backup() { | ||
chmod +w $(pwd)/sentry | ||
docker-compose run -v $(pwd)/sentry:/sentry-data/backup --rm -T -e SENTRY_LOG_LEVEL=CRITICAL web export /sentry-data/backup/backup.json | ||
} | ||
|
||
function restore() { | ||
docker-compose run --rm -T web import /etc/sentry/backup.json | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
cmd=restore | ||
source utilities/set-up-error-reporting-for-scripts.sh | ||
source utilities/helpers.sh | ||
$cmd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why we're not including the
-E
flag generally? If an error is thrown in a function, our cleanup function actually doesn't catch it properly and treats it as theEXIT
trap code instead ofERR
. Found that out in this PRhttps://www.gnu.org/software/bash/manual/html_node/The-Set-Builtin.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No good one that I know of. :)