#!/bin/bash

if [ -z "$WALE_S3_PREFIX" ]; then
    echo "Environment variable WALE_S3_PREFIX not exist"
    exit 1
fi

# WALE_S3_PREFIX:
# s3://mapsdb/wal-g/maps_db_main/9.5/

FIRST=`echo $WALE_S3_PREFIX | cut -f1-3 -d/` # s3://mapsdb
LAST=`echo $WALE_S3_PREFIX | cut -f4- -d/` # wal-g/maps_db_main9.5/

WALE_S3_PREFIX="$FIRST/monthly-$LAST" /usr/bin/wal-g $*
