Skip to content

Commit 6b061dd

Browse files
chrisroosTetrino
authored andcommitted
Fix replicate-mongodb.sh to work on linux
The `\d` in the regexp passed to grep isn't supported in the GNU version of grep. I understand that the equivalent `[[:digit:]]` should work in all implementations. The `-z` option to `tar` results in the following error on linux: ``` gzip: stdin: not in gzip format tar: Child died with signal 13 tar: Error is not recoverable: exiting now ``` The `-z` option filters the output through gzip but I don't believe this is necessary because we're explicitly `gunzip`ing the dump before passing it to `tar`. With these two changes the script runs without error on my linux development environment.
1 parent 115c09b commit 6b061dd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

bin/replicate-mongodb.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ if [[ -e "$archive_path" ]]; then
4949
echo "Skipping download - remove ${archive_path} to force a new download on the next run"
5050
else
5151
mkdir -p "$archive_dir"
52-
remote_file_name=$(aws s3 ls "s3://${bucket}/${hostname}/" | grep "\d-$database.gz" | tail -n1 | sed 's/^.* .* .* //')
52+
remote_file_name=$(aws s3 ls "s3://${bucket}/${hostname}/" | grep "[[:digit:]]-$database.gz" | tail -n1 | sed 's/^.* .* .* //')
5353
aws s3 cp "s3://${bucket}/${hostname}/${remote_file_name}" "$archive_path"
5454
fi
5555

@@ -65,7 +65,7 @@ if [[ -d "$extract_path" ]]; then
6565
fi
6666
mkdir -p "$extract_path"
6767

68-
pv "$archive_path" | gunzip | tar -zx -f - -C "$extract_path" "${database}"
68+
pv "$archive_path" | gunzip | tar -x -f - -C "$extract_path" "${database}"
6969

7070
echo "stopping running govuk-docker containers..."
7171
govuk-docker down

0 commit comments

Comments
 (0)