How do I output the result of mysqldump to the remote server via ssh?

Connect via ssh to the server, sending it commands via plink (writing them in .bat file).
My script looks like this:
C:/mypath/plink.exe -batch ^
remoteuser@remoteserver.com -pw mypassword ^
"mysqldump -u database_user -pdbpass database_name > mysqlBackup/dbdump.sql"
pause

While mysqldump is running on a remote machine, but the result writes to a file mysqlBackup/dbdump.sql on the local machine, which naturally takes a lot of time. How to specify in the command that the result should be written to a file in the same place, on the remote machine?
I would also like to drive to gzip, that is:
mysqldump -u database_user -pdbpass database_name | gzip > mysqlBackup/dbdump.sql.gz

and then actually upload the resulting backup on the local machine:
scp C:/mypath/ remoteuser@remoteserver.com:~/mysqlBackup/dbdump.sql.gz
April 3rd 20 at 18:23
3 answers
April 3rd 20 at 18:25
Solution
Found what was the problem, it turns out the escape characters in my script - " ^ " I don't understand is how influenced the script, specifically - "^" immediately before the quotation marks, which contains the transmitted command to execute on the remote machine, i.e. I copied the whole command:
C:/mypath/plink.exe -batch ^
remoteuser@remoteserver.com -pw mypassword ^
"mysqldump -u database_user -pdbpass database_name > mysqlBackup/dbdump.sql"

in one line:
C:/mypath/plink.exe -batch remoteuser@remoteserver.com -pw mypassword "mysqldump -u database_user -pdbpass database_name > mysqlBackup/dbdump.sql"

And it worked as it should be, i.e. output goes to a file mysqlBackup/dbdump.sql on the server. Amazing. I would be grateful if someone can explain this logic.
Well, you unsuccessfully used a ^, believing that he will escape the newline.
And he screened a quote, simply passing everything from mysqldump as separate arguments to plink.
This part of the string after the ">" are running on the local computer, not on the remote. - richmond.Hermann2 commented on April 3rd 20 at 18:28
@richmond.Hermann2, got it, thanks - Margarita.Kautzer commented on April 3rd 20 at 18:31
April 3rd 20 at 18:27
connect via ssh to a remote host
do what you need in the console
from the local computer running sftp on UD host (you can winscp)
taking the result
I need to implement a script that connects via ssh and runs several commands, including the mysqldump on the remote machine and copy the resulting database dump on local machine, i.e. manually via the console via ssh everything works - and to write a script which will execute a pre-written script of the team - no, that is the question - Margarita.Kautzer commented on April 3rd 20 at 18:30
@Margarita.Kautzer, if you have to work the script so it can look towards ssh key without a password - clyde_Gutkows commented on April 3rd 20 at 18:33
April 3rd 20 at 18:29
about Windu not know, and in Linux like this would work
mysqldump -u database_user -pdbpass database_name | \
gzip -c | ssh remoteuser@remoteserver.com "cat > mysqlBackup/dbdump.sql.gz"

Find more questions by tags LinuxMySQLbash