Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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
5 changes: 5 additions & 0 deletions backup.config-example
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@ GHE_NUM_SNAPSHOTS=10
# Any extra options passed to the rsync command. Nothing required by default.
#
#GHE_EXTRA_RSYNC_OPTS=""
#
# If set to 'no', GHE_DATA_DIR will not be created automatically
# and restore/backup will exit 8
#
#GHE_CREATE_DATA_DIR=yes
9 changes: 8 additions & 1 deletion share/github-backup-utils/ghe-backup-config
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,19 @@ if [ -z "$GHE_HOSTNAME" ]; then
exit 2
fi

GHE_CREATE_DATA_DIR=${GHE_CREATE_DATA_DIR:-yes}

# Check that the data directory is set and create it if it doesn't exist.
if [ ! -d "$GHE_DATA_DIR" ]; then
if [ ! -d "$GHE_DATA_DIR" ] && [ "$GHE_CREATE_DATA_DIR" = "yes" ]; then
echo "Creating the backup data directory ..." 1>&3
mkdir -p "$GHE_DATA_DIR"
fi

if [ ! -d "$GHE_DATA_DIR" ]; then
echo "Error: GHE_DATA_DIR $GHE_DATA_DIR does not exist." >&2
exit 8
fi

# Set some defaults if needed.
: ${GHE_NUM_SNAPSHOTS:=10}

Expand Down
25 changes: 25 additions & 0 deletions test/test-ghe-backup-config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,31 @@ export GHE_DATA_DIR GHE_REMOTE_DATA_DIR
cd "$ROOTDIR"
. "share/github-backup-utils/ghe-backup-config"

begin_test "ghe-backup-config GHE_CREATE_DATA_DIR disabled"
(
set -e

export GHE_DATA_DIR=$(mktemp -d -u)
. share/github-backup-utils/ghe-backup-config 2>&1 \
| grep -q "Creating the backup data directory ..."
test -d $GHE_DATA_DIR
rm -rf $GHE_DATA_DIR

export GHE_DATA_DIR=$(mktemp -d -u)
export GHE_CREATE_DATA_DIR=no
set +e
error=$(. share/github-backup-utils/ghe-backup-config 2>&1)
# should exit 8
if [ $? != 8 ]; then
exit 1
fi
set -e
echo $error | grep -q "Error: GHE_DATA_DIR .* does not exist"

rm -rf $GHE_DATA_DIR
)
end_test

begin_test "ghe-backup-config ssh_host_part"
(
set -e
Expand Down