I have a simple powershell script that is supposed to drop an existing schema and restore it from a backup, the script is basically those lines:

echo "Dropping Schema MySchema"
& $PG_SQL -d "host=$DBSERVER port=$DBSERVERPORT dbname=$DATABASE user=$DBSERVERUSER sslmode=require" -c "DROP SCHEMA MySchema CASCADE;"

echo "Restoring MySchema Schema from backup"
& $PG_RESTORE -h $DBSERVER -p $DBSERVERPORT -U $DBSERVERUSER -d $DATABASE -j 6 --no-owner --no-tablespaces --verbose $BACKUP_FILE

When the Schema is empty, it runs through the drop schema command without an issue. When the schema is not empty, it hangs forever after writing "Dropping Schema MySchema". While it hangs there, hitting Enter/Return seems to start it again and the script continues. Problem is that this script is supposed to be run by the CI so it ends up running in a 60min timeout and fails.

Any idea what could be causing such behavior or a different approach to try?

  • 2
    It's probably waiting for the password input. See e.g. here or here for a solution to automatically provide the password. – a_horse_with_no_name May 13 at 11:16
  • Thank you sir, that was indeed the issue. I had the password in my home directory but the CI was using a different user in which home directory the password file was missing. – Damir Porobic May 13 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.