The easiest way to explain this question is show the following line of code which I have in a bash script.
tar -cJf - ./my_folder | ssh user@example 'tar -xJf - && rm -r ./path-to-my_folder/my_folder && mv ./my_folder ./path-to-my_folder'
I don't fully understand how it works. (What does '-'
mean in this context?) But this is what it does:
Creates a compressed tar archive in memory and the pipe somehow pushes the tar data over ssh
The tar archive appears in
user
s root folder, it is extractedThe ssh command continues executing the stuff in the between
' ... '
, the old folder on the server side is removed usingrm
and replaced by moving the extracted folder from the user's root directory
It is obvious that this is a rather long way of doing things. It would be better if the tar archive was extracted to the correct location so that the rm
and mv
commands would not be necessary. Can this be done?
Note: I cannot use rsync.