From b3d5ff40f46bf3278b740d7d823d3b7a9495bfe1 Mon Sep 17 00:00:00 2001 From: Jorge Holgado Date: Fri, 22 Jul 2022 18:56:02 +0200 Subject: [PATCH] patch for very long file names --- get_all_pgmetadata.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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}"