Skip to content

Commit b8d5646

Browse files
committed
Initial merge
1 parent b538628 commit b8d5646

File tree

12 files changed

+1575
-650
lines changed

12 files changed

+1575
-650
lines changed

src/integration-tests/bash/archive.sh

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/bin/bash
2+
# Copyright 2017, 2018, Oracle Corporation and/or its affiliates. All rights reserved.
3+
# Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
4+
5+
#
6+
# archive.sh <source_dir> <target_dir>
7+
# - internal helper method called by run.sh
8+
# - archives directory ${1} into ${2}/IntSuite.TIMESTAMP.tar.gz
9+
# - deletes all but the 5 newest archives
10+
# - this method doesn't have any configurable env vars
11+
#
12+
13+
# trace <message>
14+
function trace {
15+
#Date reported in same format as oper-log for easier correlation. 01-22-2018T21:49:01
16+
echo "[`date '+%m-%d-%YT%H:%M:%S'`] [secs=$SECONDS] [test=archive] [fn=archive]: ""$@"
17+
}
18+
19+
function fail {
20+
trace "Error: ""$@"
21+
exit 1
22+
}
23+
24+
function archive {
25+
local SOURCE_DIR="${1?}"
26+
local ARCHIVE_DIR="${2?}"
27+
local ARCHIVE="$ARCHIVE_DIR/IntSuite.`date '+%Y%m%d%H%M%S'`.tar.gz"
28+
29+
trace About to archive a copy of \'$SOURCE_DIR\' to \'$ARCHIVE\'.
30+
31+
[ ! -d "$SOURCE_DIR" ] && fail Could not archive, could not find source directory \'$SOURCE_DIR\'.
32+
33+
mkdir -p $ARCHIVE_DIR || fail Could not archive, could not create target directory \'$ARCHIVE_DIR\'.
34+
35+
tar -czf $ARCHIVE $SOURCE_DIR 2>&1
36+
[ $? -eq 0 ] || fail "Could not archive, 'tar -czf $ARCHIVE $SOURCE_DIR' command failed."
37+
38+
find $ARCHIVE_DIR -maxdepth 1 -name "IntSuite*tar.gz" | sort -r | awk '{ if (NR>5) print $NF }' | xargs rm -f
39+
40+
trace Archived copy of \'$SOURCE_DIR\' to \'$ARCHIVE\'.
41+
}
42+
43+
archive "$1" "$2"

0 commit comments

Comments
 (0)