diff --git a/get_all_pgmetadata.sh b/get_all_pgmetadata.sh index 9094ca6..ac196c5 100755 --- a/get_all_pgmetadata.sh +++ b/get_all_pgmetadata.sh @@ -130,7 +130,18 @@ generate_split_metadata() SCHEMA="postgres" fi OUTPUTDIR="${BACKUPDIR}/${DBNAME}/${SCHEMA// /_}/${TYPE// /_}" - OUTPUTFILE="${OBJECT}.sql" + # PATCH for very long file names + OUTPUTFILE="${OBJECT::240}" + OUTPUTFILE="${OUTPUTFILE// /_}" + if [[ -f ${OUTPUTDIR}/${OUTPUTFILE}.sql ]] ; then + for ((x=1; x<1000 ;x++)) ; do + if [[ ! -f ${OUTPUTDIR}/${OUTPUTFILE}_${x}.sql ]] ; then + OUTPUTFILE="${OUTPUTFILE}_${x}" + fi + done + fi + OUTPUTFILE="${OUTPUTFILE}.sql" + mkdir -p "${OUTPUTDIR}" echo -e "${OUTPUTDIR}/${OUTPUTFILE}" echo -e "${LINE}" > "${OUTPUTDIR}/${OUTPUTFILE}"