Created
March 29, 2018 15:29
-
-
Save owulveryck/b3ea6740872ce6acd6472f167460530c to your computer and use it in GitHub Desktop.
catLastDump.sh
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
#! /bin/sh | |
DEFAULT_REMOTE=/tmp | |
usage(){ | |
{ | |
echo "$0 usage" | |
echo "Config:" | |
echo "\tENVIRONMENT" | |
echo "\tREMOTE_DIR (default to ${DEFAULT_REMOTE})" | |
} 2>&1 | |
} | |
TARGET=$1 | |
if [ -z ${ENVIRONMENT} ] | |
then | |
usage | |
exit 2 | |
fi | |
if [[ $# -lt 1 ]] | |
then | |
usage | |
exit 2 | |
fi | |
( | |
echo "ENVIRONMENT=${ENVIRONMENT}" | |
echo "REMOTE_DIR=${REMOTE_DIR:-${DEFAULT_REMOTE}}" | |
cat << \EOF | |
test -d ${REMOTE_DIR}/${ENVIRONMENT} | |
if [ $? -eq 0 ] | |
then | |
cat $(ls -Art "${REMOTE_DIR}/${ENVIRONMENT}/*.tar.gz" | tail -n1) | |
else | |
exit 1 | |
fi | |
EOF | |
) | ssh "$@" |
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
./catLastDump.sh localhost | tar -C /tmp -xzf - && echo ok || echo ko |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment