Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create tar file in ssh

Tags:

ssh

tar

I would like to tar a folder into a file. This file should not be saved on the local machine but on another which can be reached via ssh.

Can I do something like that?

tar cfv ssh://user:pass@server:/tmp/myfile.tar myfolder/
like image 251
ccman Avatar asked Feb 17 '26 03:02

ccman


2 Answers

Without the need of a temporary file:

tar cfv - myfolder/ | ssh user@server 'cat > /tmp/myfile.tar'
like image 111
golimar Avatar answered Feb 20 '26 05:02

golimar


Let's try to do this the easy way. This might be a very simplistic approach, but it gets the job done.

tar cfv myfile.tar myfolder/ && scp myfile.tar user:pass@server:/tmp/myfile.tar && rm myfile.tar

(did not test this, forgive me in case it has an error)

like image 35
W. Goeman Avatar answered Feb 20 '26 07:02

W. Goeman