Layer7 API Management

 View Only
  • 1.  "su: must be suid to work properly" error on Database restore

    Posted Jul 14, 2020 11:08 AM
    Hello

    I am trying to restore the database on Portal 4.5 and running into the following error when I run the db-restore script in Centos

    su: must be suid to work properly
    Failed to restore database from backup

    I have tried changing permissions on the backup file and script using chmod 4755 but still does not work, has has anyone else experienced this issue and if so what was the workaround.

    ------------------------------
    Wesley
    ------------------------------


  • 2.  RE: "su: must be suid to work properly" error on Database restore
    Best Answer

    Broadcom Employee
    Posted Jul 14, 2020 07:33 PM
    I guess the message is to ask you su first, ie. you might need to run the script as root user.

    Regards,
    Mark


  • 3.  RE: "su: must be suid to work properly" error on Database restore

    Posted Oct 19, 2020 11:34 AM
    Edited by David Vinell Oct 19, 2020 11:34 AM
    Hi,

    If you are using the Centos Hardened image, that error is coming from the container because you are trying to run "su -c" as "postgres", which doesn't work.
    I have modified my db-backup.sh and db-restore.sh scripts to add --user root to the docker command there, and this works well for me.

    I suspect that there might be one or two disappointed customers that when it comes to restore time, find that all their backup SQLs only contain the words "su: must be suid to work properly" instead of the actual backup.

    db-backup.sh
    docker exec -it --user root $(docker ps --format "{{.ID}}" --filter name=portal_portaldb.1) su -c 'PGPASSWORD=${POSTGRES_PASSWORD} pg_dumpall -U ${POSTGRES_USER} -c' postgres > ../backup/$name

    db-restore.sh
    docker exec -i --user root $(docker ps --format "{{.ID}}" --filter name=portal_portaldb.1) su -c 'PGPASSWORD=${POSTGRES_PASSWORD} psql -U ${POSTGRES_USER} -a postgres' postgres < $name

    Best Regards,
    DaveV.


  • 4.  RE: "su: must be suid to work properly" error on Database restore

    Posted Oct 21, 2020 02:43 PM
    Edited by Rogerio Santos Oct 21, 2020 02:57 PM

    Hi Wesley,

    to make the script work properly, just add the sentence -u 0.. so u have to modify modify the file to be the same as mine:

    #!/bin/bash

    function backup {
    if [ ! -d "../backup" ]; then
    mkdir -p ../backup
    fi

    name=postgres_backup-$(date '+%Y-%m-%d-%H-%M-%S').sql
    docker exec -it -u 0 $(docker ps -q -f name=portal_portaldb.1) su -c 'PGPASSWORD=${POSTGRES_PASSWORD} pg_dumpall -U ${POSTGRES_USER} -c' postgres > ../backup/$name
    }

    backup "$@"