Copy a file to remote server using SSHis it possible to ssh into ubuntu server with keys and from another...

Check if a string is entirely made of the same substring

Rivers without rain

555 timer FM transmitter

Pre-plastic human skin alternative

How did Captain America manage to do this?

Mistake in years of experience in resume?

How can Republicans who favour free markets, consistently express anger when they don't like the outcome of that choice?

How to stop co-workers from teasing me because I know Russian?

Map of water taps to fill bottles

Can someone publish a story that happened to you?

How do I reattach a shelf to the wall when it ripped out of the wall?

What is the most expensive material in the world that could be used to create Pun-Pun's lute?

Lock file naming pattern

Origin of 'tump' (verb) and 'tumpline' (noun)

Re-entry to Germany after vacation using blue card

Is this homebrew Wind Wave spell balanced?

How does a program know if stdout is connected to a terminal or a pipe?

Why does nature favour the Laplacian?

Combinable filters

Why do games have consumables?

To say I met a person for the first time

On The Origin of Dissonant Chords

Retrieve SObject

Critique of timeline aesthetic



Copy a file to remote server using SSH


is it possible to ssh into ubuntu server with keys and from another computer using password?copy ssh private keys to another computerWhen exactly does SSH-agent use my private_key to connect to a remote server?Permission denied to to transfer files from remote serverCopy data held by www-data over sshUsing rsync to back up a remote computer through a reverse ssh linkHow can I compress my local file and copy to remote machine and the uncompress?Copy public key to second remote user with password authentication disabledCron job : dump and scp tar dump to remote serverHow to copy file from Ubuntu computer to remote box via SSH?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







2















I want to backup a mysql database et copy it to a remote server.



I do :



mysqldump -uroot myDb>$HOME/myDb.sql && tar czf - $HOME/myDb.sql | ssh root@ip "dd of=$HOME/myDb_$(date +%Y%m%d%H%M%S).tar.gz" $HOME/backup/myDb


It doesn't work, I am getting :



dd: opérande «/home/backup/myDb» non reconnu


When I do



mysqldump -uroot myDb>$HOME/myDb.sql && tar czf - $HOME/myDb.sql | ssh root@ip "dd of=$HOME/myDb_$(date +%Y%m%d%H%M%S).tar.gz"


It works but I want to copy the file in folder on my remote server, not at the root folder.



Is there a way to do that?



Thanks










share|improve this question





























    2















    I want to backup a mysql database et copy it to a remote server.



    I do :



    mysqldump -uroot myDb>$HOME/myDb.sql && tar czf - $HOME/myDb.sql | ssh root@ip "dd of=$HOME/myDb_$(date +%Y%m%d%H%M%S).tar.gz" $HOME/backup/myDb


    It doesn't work, I am getting :



    dd: opérande «/home/backup/myDb» non reconnu


    When I do



    mysqldump -uroot myDb>$HOME/myDb.sql && tar czf - $HOME/myDb.sql | ssh root@ip "dd of=$HOME/myDb_$(date +%Y%m%d%H%M%S).tar.gz"


    It works but I want to copy the file in folder on my remote server, not at the root folder.



    Is there a way to do that?



    Thanks










    share|improve this question

























      2












      2








      2








      I want to backup a mysql database et copy it to a remote server.



      I do :



      mysqldump -uroot myDb>$HOME/myDb.sql && tar czf - $HOME/myDb.sql | ssh root@ip "dd of=$HOME/myDb_$(date +%Y%m%d%H%M%S).tar.gz" $HOME/backup/myDb


      It doesn't work, I am getting :



      dd: opérande «/home/backup/myDb» non reconnu


      When I do



      mysqldump -uroot myDb>$HOME/myDb.sql && tar czf - $HOME/myDb.sql | ssh root@ip "dd of=$HOME/myDb_$(date +%Y%m%d%H%M%S).tar.gz"


      It works but I want to copy the file in folder on my remote server, not at the root folder.



      Is there a way to do that?



      Thanks










      share|improve this question














      I want to backup a mysql database et copy it to a remote server.



      I do :



      mysqldump -uroot myDb>$HOME/myDb.sql && tar czf - $HOME/myDb.sql | ssh root@ip "dd of=$HOME/myDb_$(date +%Y%m%d%H%M%S).tar.gz" $HOME/backup/myDb


      It doesn't work, I am getting :



      dd: opérande «/home/backup/myDb» non reconnu


      When I do



      mysqldump -uroot myDb>$HOME/myDb.sql && tar czf - $HOME/myDb.sql | ssh root@ip "dd of=$HOME/myDb_$(date +%Y%m%d%H%M%S).tar.gz"


      It works but I want to copy the file in folder on my remote server, not at the root folder.



      Is there a way to do that?



      Thanks







      ssh






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 2 hours ago









      thomasthomas

      85118




      85118






















          1 Answer
          1






          active

          oldest

          votes


















          2














          Is this not easier?



          d = $(date +%Y%m%d%H%M%S)
          mysqldump -uroot myDb>$HOME/myDb.$d.sql
          tar czf - $HOME/myDb.$d.sql
          scp $HOME/myDb.$d.sql root@ip:$HOME/backup/


          The mistake in your command: the last part is seen as part of the dd command. Not as part of the ssh command.



          ===



          regarding comments:




          the thing is that when the scp is performed it doesn"t know the exact name of the file because of the date/hour/second suffix.




          That variable "d" does not change its contents over time:



          rinzwind@schijfwereld:~$ d=$(date +%Y%m%d%H%M%S)
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534





          share|improve this answer


























          • the problem is that I need to suffix the file with date/hour/second before scp it.

            – thomas
            2 hours ago











          • so do that too ;-) 1 sec. There: set the date to a variable 1st so the variable stays the same and then re-apply it.

            – Rinzwind
            2 hours ago













          • the thing is that when the scp is performed it doesn"t know the exact name of the file because of the date/hour/second suffix. So I cant scp it. The solution with the ssh works except that I don't know how to go in a particular folder in the remote server.

            – thomas
            2 hours ago











          • and that's why you create a variable. The value of "d" does NOT change. sorry but "scp" is the command to copy files to another server. I don't see how ssh can be better than the command that is suppose to do what you want.

            – Rinzwind
            1 hour ago














          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "89"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1138588%2fcopy-a-file-to-remote-server-using-ssh%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          Is this not easier?



          d = $(date +%Y%m%d%H%M%S)
          mysqldump -uroot myDb>$HOME/myDb.$d.sql
          tar czf - $HOME/myDb.$d.sql
          scp $HOME/myDb.$d.sql root@ip:$HOME/backup/


          The mistake in your command: the last part is seen as part of the dd command. Not as part of the ssh command.



          ===



          regarding comments:




          the thing is that when the scp is performed it doesn"t know the exact name of the file because of the date/hour/second suffix.




          That variable "d" does not change its contents over time:



          rinzwind@schijfwereld:~$ d=$(date +%Y%m%d%H%M%S)
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534





          share|improve this answer


























          • the problem is that I need to suffix the file with date/hour/second before scp it.

            – thomas
            2 hours ago











          • so do that too ;-) 1 sec. There: set the date to a variable 1st so the variable stays the same and then re-apply it.

            – Rinzwind
            2 hours ago













          • the thing is that when the scp is performed it doesn"t know the exact name of the file because of the date/hour/second suffix. So I cant scp it. The solution with the ssh works except that I don't know how to go in a particular folder in the remote server.

            – thomas
            2 hours ago











          • and that's why you create a variable. The value of "d" does NOT change. sorry but "scp" is the command to copy files to another server. I don't see how ssh can be better than the command that is suppose to do what you want.

            – Rinzwind
            1 hour ago


















          2














          Is this not easier?



          d = $(date +%Y%m%d%H%M%S)
          mysqldump -uroot myDb>$HOME/myDb.$d.sql
          tar czf - $HOME/myDb.$d.sql
          scp $HOME/myDb.$d.sql root@ip:$HOME/backup/


          The mistake in your command: the last part is seen as part of the dd command. Not as part of the ssh command.



          ===



          regarding comments:




          the thing is that when the scp is performed it doesn"t know the exact name of the file because of the date/hour/second suffix.




          That variable "d" does not change its contents over time:



          rinzwind@schijfwereld:~$ d=$(date +%Y%m%d%H%M%S)
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534





          share|improve this answer


























          • the problem is that I need to suffix the file with date/hour/second before scp it.

            – thomas
            2 hours ago











          • so do that too ;-) 1 sec. There: set the date to a variable 1st so the variable stays the same and then re-apply it.

            – Rinzwind
            2 hours ago













          • the thing is that when the scp is performed it doesn"t know the exact name of the file because of the date/hour/second suffix. So I cant scp it. The solution with the ssh works except that I don't know how to go in a particular folder in the remote server.

            – thomas
            2 hours ago











          • and that's why you create a variable. The value of "d" does NOT change. sorry but "scp" is the command to copy files to another server. I don't see how ssh can be better than the command that is suppose to do what you want.

            – Rinzwind
            1 hour ago
















          2












          2








          2







          Is this not easier?



          d = $(date +%Y%m%d%H%M%S)
          mysqldump -uroot myDb>$HOME/myDb.$d.sql
          tar czf - $HOME/myDb.$d.sql
          scp $HOME/myDb.$d.sql root@ip:$HOME/backup/


          The mistake in your command: the last part is seen as part of the dd command. Not as part of the ssh command.



          ===



          regarding comments:




          the thing is that when the scp is performed it doesn"t know the exact name of the file because of the date/hour/second suffix.




          That variable "d" does not change its contents over time:



          rinzwind@schijfwereld:~$ d=$(date +%Y%m%d%H%M%S)
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534





          share|improve this answer















          Is this not easier?



          d = $(date +%Y%m%d%H%M%S)
          mysqldump -uroot myDb>$HOME/myDb.$d.sql
          tar czf - $HOME/myDb.$d.sql
          scp $HOME/myDb.$d.sql root@ip:$HOME/backup/


          The mistake in your command: the last part is seen as part of the dd command. Not as part of the ssh command.



          ===



          regarding comments:




          the thing is that when the scp is performed it doesn"t know the exact name of the file because of the date/hour/second suffix.




          That variable "d" does not change its contents over time:



          rinzwind@schijfwereld:~$ d=$(date +%Y%m%d%H%M%S)
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534
          rinzwind@schijfwereld:~$ echo "$d"
          20190427115534






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 1 hour ago

























          answered 2 hours ago









          RinzwindRinzwind

          211k28406541




          211k28406541













          • the problem is that I need to suffix the file with date/hour/second before scp it.

            – thomas
            2 hours ago











          • so do that too ;-) 1 sec. There: set the date to a variable 1st so the variable stays the same and then re-apply it.

            – Rinzwind
            2 hours ago













          • the thing is that when the scp is performed it doesn"t know the exact name of the file because of the date/hour/second suffix. So I cant scp it. The solution with the ssh works except that I don't know how to go in a particular folder in the remote server.

            – thomas
            2 hours ago











          • and that's why you create a variable. The value of "d" does NOT change. sorry but "scp" is the command to copy files to another server. I don't see how ssh can be better than the command that is suppose to do what you want.

            – Rinzwind
            1 hour ago





















          • the problem is that I need to suffix the file with date/hour/second before scp it.

            – thomas
            2 hours ago











          • so do that too ;-) 1 sec. There: set the date to a variable 1st so the variable stays the same and then re-apply it.

            – Rinzwind
            2 hours ago













          • the thing is that when the scp is performed it doesn"t know the exact name of the file because of the date/hour/second suffix. So I cant scp it. The solution with the ssh works except that I don't know how to go in a particular folder in the remote server.

            – thomas
            2 hours ago











          • and that's why you create a variable. The value of "d" does NOT change. sorry but "scp" is the command to copy files to another server. I don't see how ssh can be better than the command that is suppose to do what you want.

            – Rinzwind
            1 hour ago



















          the problem is that I need to suffix the file with date/hour/second before scp it.

          – thomas
          2 hours ago





          the problem is that I need to suffix the file with date/hour/second before scp it.

          – thomas
          2 hours ago













          so do that too ;-) 1 sec. There: set the date to a variable 1st so the variable stays the same and then re-apply it.

          – Rinzwind
          2 hours ago







          so do that too ;-) 1 sec. There: set the date to a variable 1st so the variable stays the same and then re-apply it.

          – Rinzwind
          2 hours ago















          the thing is that when the scp is performed it doesn"t know the exact name of the file because of the date/hour/second suffix. So I cant scp it. The solution with the ssh works except that I don't know how to go in a particular folder in the remote server.

          – thomas
          2 hours ago





          the thing is that when the scp is performed it doesn"t know the exact name of the file because of the date/hour/second suffix. So I cant scp it. The solution with the ssh works except that I don't know how to go in a particular folder in the remote server.

          – thomas
          2 hours ago













          and that's why you create a variable. The value of "d" does NOT change. sorry but "scp" is the command to copy files to another server. I don't see how ssh can be better than the command that is suppose to do what you want.

          – Rinzwind
          1 hour ago







          and that's why you create a variable. The value of "d" does NOT change. sorry but "scp" is the command to copy files to another server. I don't see how ssh can be better than the command that is suppose to do what you want.

          – Rinzwind
          1 hour ago




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Ask Ubuntu!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1138588%2fcopy-a-file-to-remote-server-using-ssh%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          (145452) 2005 RN43 Классификация | Примечания | Ссылки |...

          Щит и меч (фильм) Содержание Названия серий | Сюжет |...

          Энтрерриос (город) Содержание История | Географическое...