Rsync is syncing $HOME instead of the provided directory

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1















Any idea why this rsync command could be syncing contents of a home directory instead of the actual path provided?



echo "$REMOTE_STORAGE_PATH: $REMOTE_STORAGE_PATH/files/"

rsync -zqr -e "ssh -p $REMOTE_PORT" --delete $REMOTE_USER@$REMOTE_SERVER:"$REMOTE_STORAGE_PATH/files/" "$FILES_PATH"


REMOTE_STORAGE_PATHhave a correct value (/var/storage), files I want to sync are in /var/storage/files. Yet, what is being synced is a content of the home directory of my REMOTE_USER. Like... what even can cause this? Any ideas?



REMOTE_USER is the owner of the REMOTE_STORAGE_PATH directory, and files subdirectory.



Actually, the most baffling part is that in the same script, almost just before that, I have almost exactly the same line of code:



rsync -zqr -e "ssh -p $REMOTE_PORT" --delete --progress $REMOTE_USER@$REMOTE_SERVER:"$REMOTE_STORAGE_PATH/database.sql" "$DUMPS_PATH/$TARGET.sql"


And that syncs correctly. Like... what?










share|improve this question
























  • Did you run the script with bash -x to see what the actual command used looks like?

    – Kusalananda
    Feb 22 at 13:49











  • It looks fine: + rsync -zqr -e 'ssh -p 20022' --delete --progress luken@xxx:/var/storage/files/ /home/luken/srv/http/projects/2014/xxx/scripts/../env/dev/php/resources/files (just censored few bits). And it still synced $HOME... (I added --progress as a desperate attempt to make it the same as the previous one, to see if it will change anything, but it shouldn't matter).

    – Łukasz Zaroda
    Feb 22 at 14:01












  • Could you just also have a look at the actual files under /var/storage/files on the remote host as a sanity check, just to see whether the files there are the files that you expect to be there?

    – Kusalananda
    Feb 22 at 14:04












  • OMG, I cannot believe, haha, you were right, although I have no idea how the content of files ended up as it ended. Well, you can post it as an answer I guess, that's the peak of my stupidity this year I guess.

    – Łukasz Zaroda
    Feb 22 at 14:08















1















Any idea why this rsync command could be syncing contents of a home directory instead of the actual path provided?



echo "$REMOTE_STORAGE_PATH: $REMOTE_STORAGE_PATH/files/"

rsync -zqr -e "ssh -p $REMOTE_PORT" --delete $REMOTE_USER@$REMOTE_SERVER:"$REMOTE_STORAGE_PATH/files/" "$FILES_PATH"


REMOTE_STORAGE_PATHhave a correct value (/var/storage), files I want to sync are in /var/storage/files. Yet, what is being synced is a content of the home directory of my REMOTE_USER. Like... what even can cause this? Any ideas?



REMOTE_USER is the owner of the REMOTE_STORAGE_PATH directory, and files subdirectory.



Actually, the most baffling part is that in the same script, almost just before that, I have almost exactly the same line of code:



rsync -zqr -e "ssh -p $REMOTE_PORT" --delete --progress $REMOTE_USER@$REMOTE_SERVER:"$REMOTE_STORAGE_PATH/database.sql" "$DUMPS_PATH/$TARGET.sql"


And that syncs correctly. Like... what?










share|improve this question
























  • Did you run the script with bash -x to see what the actual command used looks like?

    – Kusalananda
    Feb 22 at 13:49











  • It looks fine: + rsync -zqr -e 'ssh -p 20022' --delete --progress luken@xxx:/var/storage/files/ /home/luken/srv/http/projects/2014/xxx/scripts/../env/dev/php/resources/files (just censored few bits). And it still synced $HOME... (I added --progress as a desperate attempt to make it the same as the previous one, to see if it will change anything, but it shouldn't matter).

    – Łukasz Zaroda
    Feb 22 at 14:01












  • Could you just also have a look at the actual files under /var/storage/files on the remote host as a sanity check, just to see whether the files there are the files that you expect to be there?

    – Kusalananda
    Feb 22 at 14:04












  • OMG, I cannot believe, haha, you were right, although I have no idea how the content of files ended up as it ended. Well, you can post it as an answer I guess, that's the peak of my stupidity this year I guess.

    – Łukasz Zaroda
    Feb 22 at 14:08













1












1








1








Any idea why this rsync command could be syncing contents of a home directory instead of the actual path provided?



echo "$REMOTE_STORAGE_PATH: $REMOTE_STORAGE_PATH/files/"

rsync -zqr -e "ssh -p $REMOTE_PORT" --delete $REMOTE_USER@$REMOTE_SERVER:"$REMOTE_STORAGE_PATH/files/" "$FILES_PATH"


REMOTE_STORAGE_PATHhave a correct value (/var/storage), files I want to sync are in /var/storage/files. Yet, what is being synced is a content of the home directory of my REMOTE_USER. Like... what even can cause this? Any ideas?



REMOTE_USER is the owner of the REMOTE_STORAGE_PATH directory, and files subdirectory.



Actually, the most baffling part is that in the same script, almost just before that, I have almost exactly the same line of code:



rsync -zqr -e "ssh -p $REMOTE_PORT" --delete --progress $REMOTE_USER@$REMOTE_SERVER:"$REMOTE_STORAGE_PATH/database.sql" "$DUMPS_PATH/$TARGET.sql"


And that syncs correctly. Like... what?










share|improve this question
















Any idea why this rsync command could be syncing contents of a home directory instead of the actual path provided?



echo "$REMOTE_STORAGE_PATH: $REMOTE_STORAGE_PATH/files/"

rsync -zqr -e "ssh -p $REMOTE_PORT" --delete $REMOTE_USER@$REMOTE_SERVER:"$REMOTE_STORAGE_PATH/files/" "$FILES_PATH"


REMOTE_STORAGE_PATHhave a correct value (/var/storage), files I want to sync are in /var/storage/files. Yet, what is being synced is a content of the home directory of my REMOTE_USER. Like... what even can cause this? Any ideas?



REMOTE_USER is the owner of the REMOTE_STORAGE_PATH directory, and files subdirectory.



Actually, the most baffling part is that in the same script, almost just before that, I have almost exactly the same line of code:



rsync -zqr -e "ssh -p $REMOTE_PORT" --delete --progress $REMOTE_USER@$REMOTE_SERVER:"$REMOTE_STORAGE_PATH/database.sql" "$DUMPS_PATH/$TARGET.sql"


And that syncs correctly. Like... what?







bash rsync






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 22 at 13:42







Łukasz Zaroda

















asked Feb 22 at 13:31









Łukasz ZarodaŁukasz Zaroda

1,1572913




1,1572913












  • Did you run the script with bash -x to see what the actual command used looks like?

    – Kusalananda
    Feb 22 at 13:49











  • It looks fine: + rsync -zqr -e 'ssh -p 20022' --delete --progress luken@xxx:/var/storage/files/ /home/luken/srv/http/projects/2014/xxx/scripts/../env/dev/php/resources/files (just censored few bits). And it still synced $HOME... (I added --progress as a desperate attempt to make it the same as the previous one, to see if it will change anything, but it shouldn't matter).

    – Łukasz Zaroda
    Feb 22 at 14:01












  • Could you just also have a look at the actual files under /var/storage/files on the remote host as a sanity check, just to see whether the files there are the files that you expect to be there?

    – Kusalananda
    Feb 22 at 14:04












  • OMG, I cannot believe, haha, you were right, although I have no idea how the content of files ended up as it ended. Well, you can post it as an answer I guess, that's the peak of my stupidity this year I guess.

    – Łukasz Zaroda
    Feb 22 at 14:08

















  • Did you run the script with bash -x to see what the actual command used looks like?

    – Kusalananda
    Feb 22 at 13:49











  • It looks fine: + rsync -zqr -e 'ssh -p 20022' --delete --progress luken@xxx:/var/storage/files/ /home/luken/srv/http/projects/2014/xxx/scripts/../env/dev/php/resources/files (just censored few bits). And it still synced $HOME... (I added --progress as a desperate attempt to make it the same as the previous one, to see if it will change anything, but it shouldn't matter).

    – Łukasz Zaroda
    Feb 22 at 14:01












  • Could you just also have a look at the actual files under /var/storage/files on the remote host as a sanity check, just to see whether the files there are the files that you expect to be there?

    – Kusalananda
    Feb 22 at 14:04












  • OMG, I cannot believe, haha, you were right, although I have no idea how the content of files ended up as it ended. Well, you can post it as an answer I guess, that's the peak of my stupidity this year I guess.

    – Łukasz Zaroda
    Feb 22 at 14:08
















Did you run the script with bash -x to see what the actual command used looks like?

– Kusalananda
Feb 22 at 13:49





Did you run the script with bash -x to see what the actual command used looks like?

– Kusalananda
Feb 22 at 13:49













It looks fine: + rsync -zqr -e 'ssh -p 20022' --delete --progress luken@xxx:/var/storage/files/ /home/luken/srv/http/projects/2014/xxx/scripts/../env/dev/php/resources/files (just censored few bits). And it still synced $HOME... (I added --progress as a desperate attempt to make it the same as the previous one, to see if it will change anything, but it shouldn't matter).

– Łukasz Zaroda
Feb 22 at 14:01






It looks fine: + rsync -zqr -e 'ssh -p 20022' --delete --progress luken@xxx:/var/storage/files/ /home/luken/srv/http/projects/2014/xxx/scripts/../env/dev/php/resources/files (just censored few bits). And it still synced $HOME... (I added --progress as a desperate attempt to make it the same as the previous one, to see if it will change anything, but it shouldn't matter).

– Łukasz Zaroda
Feb 22 at 14:01














Could you just also have a look at the actual files under /var/storage/files on the remote host as a sanity check, just to see whether the files there are the files that you expect to be there?

– Kusalananda
Feb 22 at 14:04






Could you just also have a look at the actual files under /var/storage/files on the remote host as a sanity check, just to see whether the files there are the files that you expect to be there?

– Kusalananda
Feb 22 at 14:04














OMG, I cannot believe, haha, you were right, although I have no idea how the content of files ended up as it ended. Well, you can post it as an answer I guess, that's the peak of my stupidity this year I guess.

– Łukasz Zaroda
Feb 22 at 14:08





OMG, I cannot believe, haha, you were right, although I have no idea how the content of files ended up as it ended. Well, you can post it as an answer I guess, that's the peak of my stupidity this year I guess.

– Łukasz Zaroda
Feb 22 at 14:08










1 Answer
1






active

oldest

votes


















0














The issue was resolved in comments.



There was no issue whatsoever with the rsync command. Rather, the remote directory contained files not actually expected to be there.




A short note about the command though,



rsync -zqr 
-e "ssh -p $REMOTE_PORT"
--delete
$REMOTE_USER@$REMOTE_SERVER:"$REMOTE_STORAGE_PATH/files/"
"$FILES_PATH"


This contains a number of unquoted variable expansions. For safety, I would write this as



rsync -zqr 
-e "ssh -p '$REMOTE_PORT'"
--delete
"$REMOTE_USER@$REMOTE_SERVER:$REMOTE_STORAGE_PATH/files/"
"$FILES_PATH"


Note that using $variable is exactly the same as $variable unless the immediately following character is a valid character in a variable name, as in $variablex.



In a script, I would additionally always use the long options, if possible, for documentation purposes. But that's my personal opinion. And I would probably use --archive rather than --recursive, to also sync file metadata (timestamps etc.)



rsync --compress --quiet --archive 
--rsh="ssh -p '$REMOTE_PORT'"
--delete
"$REMOTE_USER@$REMOTE_SERVER:$REMOTE_STORAGE_PATH/files/"
"$FILES_PATH"





share|improve this answer
























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    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: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    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%2funix.stackexchange.com%2fquestions%2f502303%2frsync-is-syncing-home-instead-of-the-provided-directory%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









    0














    The issue was resolved in comments.



    There was no issue whatsoever with the rsync command. Rather, the remote directory contained files not actually expected to be there.




    A short note about the command though,



    rsync -zqr 
    -e "ssh -p $REMOTE_PORT"
    --delete
    $REMOTE_USER@$REMOTE_SERVER:"$REMOTE_STORAGE_PATH/files/"
    "$FILES_PATH"


    This contains a number of unquoted variable expansions. For safety, I would write this as



    rsync -zqr 
    -e "ssh -p '$REMOTE_PORT'"
    --delete
    "$REMOTE_USER@$REMOTE_SERVER:$REMOTE_STORAGE_PATH/files/"
    "$FILES_PATH"


    Note that using $variable is exactly the same as $variable unless the immediately following character is a valid character in a variable name, as in $variablex.



    In a script, I would additionally always use the long options, if possible, for documentation purposes. But that's my personal opinion. And I would probably use --archive rather than --recursive, to also sync file metadata (timestamps etc.)



    rsync --compress --quiet --archive 
    --rsh="ssh -p '$REMOTE_PORT'"
    --delete
    "$REMOTE_USER@$REMOTE_SERVER:$REMOTE_STORAGE_PATH/files/"
    "$FILES_PATH"





    share|improve this answer





























      0














      The issue was resolved in comments.



      There was no issue whatsoever with the rsync command. Rather, the remote directory contained files not actually expected to be there.




      A short note about the command though,



      rsync -zqr 
      -e "ssh -p $REMOTE_PORT"
      --delete
      $REMOTE_USER@$REMOTE_SERVER:"$REMOTE_STORAGE_PATH/files/"
      "$FILES_PATH"


      This contains a number of unquoted variable expansions. For safety, I would write this as



      rsync -zqr 
      -e "ssh -p '$REMOTE_PORT'"
      --delete
      "$REMOTE_USER@$REMOTE_SERVER:$REMOTE_STORAGE_PATH/files/"
      "$FILES_PATH"


      Note that using $variable is exactly the same as $variable unless the immediately following character is a valid character in a variable name, as in $variablex.



      In a script, I would additionally always use the long options, if possible, for documentation purposes. But that's my personal opinion. And I would probably use --archive rather than --recursive, to also sync file metadata (timestamps etc.)



      rsync --compress --quiet --archive 
      --rsh="ssh -p '$REMOTE_PORT'"
      --delete
      "$REMOTE_USER@$REMOTE_SERVER:$REMOTE_STORAGE_PATH/files/"
      "$FILES_PATH"





      share|improve this answer



























        0












        0








        0







        The issue was resolved in comments.



        There was no issue whatsoever with the rsync command. Rather, the remote directory contained files not actually expected to be there.




        A short note about the command though,



        rsync -zqr 
        -e "ssh -p $REMOTE_PORT"
        --delete
        $REMOTE_USER@$REMOTE_SERVER:"$REMOTE_STORAGE_PATH/files/"
        "$FILES_PATH"


        This contains a number of unquoted variable expansions. For safety, I would write this as



        rsync -zqr 
        -e "ssh -p '$REMOTE_PORT'"
        --delete
        "$REMOTE_USER@$REMOTE_SERVER:$REMOTE_STORAGE_PATH/files/"
        "$FILES_PATH"


        Note that using $variable is exactly the same as $variable unless the immediately following character is a valid character in a variable name, as in $variablex.



        In a script, I would additionally always use the long options, if possible, for documentation purposes. But that's my personal opinion. And I would probably use --archive rather than --recursive, to also sync file metadata (timestamps etc.)



        rsync --compress --quiet --archive 
        --rsh="ssh -p '$REMOTE_PORT'"
        --delete
        "$REMOTE_USER@$REMOTE_SERVER:$REMOTE_STORAGE_PATH/files/"
        "$FILES_PATH"





        share|improve this answer















        The issue was resolved in comments.



        There was no issue whatsoever with the rsync command. Rather, the remote directory contained files not actually expected to be there.




        A short note about the command though,



        rsync -zqr 
        -e "ssh -p $REMOTE_PORT"
        --delete
        $REMOTE_USER@$REMOTE_SERVER:"$REMOTE_STORAGE_PATH/files/"
        "$FILES_PATH"


        This contains a number of unquoted variable expansions. For safety, I would write this as



        rsync -zqr 
        -e "ssh -p '$REMOTE_PORT'"
        --delete
        "$REMOTE_USER@$REMOTE_SERVER:$REMOTE_STORAGE_PATH/files/"
        "$FILES_PATH"


        Note that using $variable is exactly the same as $variable unless the immediately following character is a valid character in a variable name, as in $variablex.



        In a script, I would additionally always use the long options, if possible, for documentation purposes. But that's my personal opinion. And I would probably use --archive rather than --recursive, to also sync file metadata (timestamps etc.)



        rsync --compress --quiet --archive 
        --rsh="ssh -p '$REMOTE_PORT'"
        --delete
        "$REMOTE_USER@$REMOTE_SERVER:$REMOTE_STORAGE_PATH/files/"
        "$FILES_PATH"






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Feb 22 at 14:20

























        answered Feb 22 at 14:09









        KusalanandaKusalananda

        136k17257426




        136k17257426



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • 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%2funix.stackexchange.com%2fquestions%2f502303%2frsync-is-syncing-home-instead-of-the-provided-directory%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

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay