The script does not stop executing
Asked by yadamenko:

```
- step: &restoreDefaultDatabase
    name: 'Deploy to Environment'
    script:
      - pipe: atlassian/ssh-run:0.8.0
        variables:
          SSH_USER: $REMOTE_SERVER_USER
          SERVER: $REMOTE_SERVER_HOST
          MODE: 'command'
          COMMAND: |
            export MYSQL_PWD="$DB_PASSWD" &&
            echo "DROP DATABASE" &&
            mysql -u$DB_USER -e "DROP DATABASE IF EXISTS $DB_NAME;"  &&
            echo "CREATE DATABASE" &&
            mysql -u$DB_USER -e "CREATE DATABASE IF NOT EXISTS $DB_NAME DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;"  &&
            echo "IMPORT DATABASE" &&
            mysql -u$DB_USER -e "SET foreign_key_checks = 0;" &&
            mysql --force -u$DB_USER $DB_NAME < /home/qwe/backup/qwe_database.sql > /home/qwe/staging3/backup_import.log 2>&1 || true &&
            mysql -u$DB_USER -e "SET foreign_key_checks = 1;" &&
            cat /home/qwe/staging3/backup_import.log
    artifacts:
      - /home/qwe/staging3/backup_import.log
```

This is my script I do a database import into mysql. It takes about 10-15 minutes. I can see that the import is done from phpMyAdmin But this step keeps running without stopping.  

keep runing on this line

mysql --force -u$DB_USER $DB_NAME \< /home/qwe/backup/grayfish_database.sql \> /home/qwe/staging3/backup_import.log 2\>\&1 \|\| true \&\&


Answers:
author: Theodora Boudale
body: Hi [@yadamenko](/t5/user/viewprofilepage/user-id/5535238) and welcome to the community!

The mysql command that is stuck may not be returning an exit code. I see that you are redirecting output to a log file on that server; you can check that file for indications on what the command is doing.

I also suggest checking if this works outside of Pipelines, to narrow down whether this is a Pipelines specific issue or not. If you have SSH access to this server from your computer, you can connect to that server via SSH and execute the whole command you are running from Pipelines.

Another thing to check would be from Pipelines, but without the pipe. You can install an SSH client during that step (if one is not already present in that step's Docker image) and then use an SSH command to connect to your server and run the command you are running with the pipe.

Kind regards,  
Theodora

comments: author: yadamenko
body: Hi [@Theodora Boudale](/t5/user/viewprofilepage/user-id/818086), thanks for the answer.  
I have already solved this problem with an SSH connection. Where everything works as I expect it to.  
In the pip documentation, it was just written that if you have any problems you can post here.


author: Theodora Boudale
body: Hi,

Thank you for your reply, it's good to hear that you have already solved this.

Can you please confirm, does your solution concern running this command with an SSH command without the pipe? Does the issue occur with the pipe only and not occur when you use an SSH command to connect to your server?

Kind regards,  
Theodora


author: yadamenko
body: Yep,   
The problem with database immortization occurs only when using pipe, if you do the same procedure via SSH - everything works.


Tags: bitbucket-cloud

bitbucket-pipelines

cloud

pipes

ssh