#!/bin/bash set -o nounset set -o errexit set -o pipefail SCRIPT_PATH="$(readlink -f "$0")" SCRIPT_NAME="${SCRIPT_PATH##*/}" SERVERID="00" usage() { echo "usage: ${SCRIPT_NAME} " exit 1 } [[ $# -gt 0 ]] || usage TOPDIR="$1" cd "/var/piler/store/${SERVERID}" for i in "$TOPDIR"/*; do pushd "$i" > /dev/null d="$(basename "$i")" zip -r -0 -q -m "${TOPDIR}_${d}.zip" . popd > /dev/null done