Skip to content

Commit

Permalink
Add configuration options for compressing the whole dir
Browse files Browse the repository at this point in the history
* COMPRESSED_PATH env var can be used to define where to store the
archive created. By default the archive is stored in the root of
the gather directory
* DELETE_AFTER_COMPRESSION env var can be used to define whether the
uncompressed files are deleted after the compression is done. By
default the uncompressed files are also kept. If DELETE_AFTER_COMPRESSION
is set to 1 then the files are deleted.
  • Loading branch information
gibizer committed Sep 6, 2024
1 parent 6172027 commit 9633c23
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ This is the list of available environmental variables:
default (and preserves the default behavior required in a production environment).
However, if set to 1, it dumps secrets and services config files without masking
sensitive data.
- `COMPRESSED_PATH`: defines the path to store the compressed form of the
gathered data
- `DELETE_AFTER_COMPRESSION`: 0 or 1. When set to 1 the uncompressed data is
deleted after the archive is created. Defaulted to 0.

### Inspect gathered data

Expand Down
19 changes: 17 additions & 2 deletions collection-scripts/gather_run
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,24 @@ wait_bg
# Create rotated log symlinks after everything else has finished
rotated_logs_symlinks

# create an easy to download tar from the whole content
# The path to store the compressed result
export COMPRESSED_PATH=${COMPRESSED_PATH:-"${BASE_COLLECTION_PATH}"}
# whether to delete or keep the uncompressed files.
# Defaults to keep them.
export DELETE_AFTER_COMPRESSION=${DELETE_AFTER_COMPRESSION:-0}

# create an easy to download tar.xz from the whole content
archive="${COMPRESSED_PATH}/must-gather.tar.xz"

tar \
--exclude='must-gather.tar.xz' \
--warning=no-file-changed --ignore-failed \
-cJf \
"${BASE_COLLECTION_PATH}/must-gather.tar.xz" "${BASE_COLLECTION_PATH}" || true
"${archive}" "${BASE_COLLECTION_PATH}" || true

echo "The ${archive} now can be attached to the support case."

if [[ ${DELETE_AFTER_COMPRESSION} -eq 1 ]]; then
find "${BASE_COLLECTION_PATH}" \
-mindepth 1 -not -path "*must-gather.tar.xz*" -delete
fi

0 comments on commit 9633c23

Please sign in to comment.