File tree Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Expand file tree Collapse file tree 1 file changed +25
-4
lines changed Original file line number Diff line number Diff line change @@ -4,8 +4,6 @@ CONTAINER=lomake_db
44SERVICE_NAME=db
55DB_NAME=postgres
66
7- current_date=$( date +" %Y%m%d" )
8- FILE_NAME=" lomake_${current_date} .sql.gz"
97FOLDER_NAME=" lomake"
108
119PROJECT_ROOT=$( dirname $( dirname $( realpath " $0 " ) ) )
3230echo " Creating backups folder"
3331mkdir -p ${BACKUPS}
3432
35- echo " Fetching a new dump"
33+ echo " Listing available backups in S3 bucket..."
34+ backup_files=$( s3cmd -c " $S3_CONF " ls " s3://psyduck/${FOLDER_NAME} /" | awk ' {print $4}' | grep ' \.sql\.gz$' )
3635
37- s3cmd -c $S3_CONF get " s3://psyduck/${FOLDER_NAME} /${FILE_NAME} " $BACKUPS
36+ if [ -z " $backup_files " ]; then
37+ echo " No backup files found in S3 bucket!"
38+ exit 1
39+ fi
40+
41+ echo " Available backups:"
42+ select chosen_backup in $backup_files ; do
43+ if [ -n " $chosen_backup " ]; then
44+ echo " You selected: $chosen_backup "
45+ FILE_NAME=$( basename " $chosen_backup " )
46+ break
47+ else
48+ echo " Invalid selection. Please select a valid backup number."
49+ fi
50+ done
51+
52+ echo " Fetching the selected dump: $FILE_NAME "
53+ s3cmd -c " $S3_CONF " get " $chosen_backup " " $BACKUPS "
54+
55+ if [ ! -f " ${BACKUPS}${FILE_NAME} " ]; then
56+ echo " Download failed or file not found: ${BACKUPS}${FILE_NAME} "
57+ exit 1
58+ fi
3859
3960echo " Removing database and related volume"
4061docker-compose -f $DOCKER_COMPOSE down -v
You can’t perform that action at this time.
0 commit comments