How do I compress the contents of a folder using the tar command on an Unix system over SSH?

link|improve this question
Sounds like a question for Server Fault (serverfault.com) – RonK May 21 '11 at 20:07
@RonK: Could you explain why? Because it sure doesn't belong there... – Tom Wijsman May 21 '11 at 21:32
Because that is where I post such questions :-) . Any way - this comment was added before the question was migrated. – RonK May 22 '11 at 5:08
feedback

migrated from stackoverflow.com May 21 '11 at 20:08

This question came from our site for professional and enthusiast programmers.

3 Answers

From tar --help:

Examples:
  tar -cf archive.tar foo bar  # Create archive.tar from files foo and bar.
  tar -tvf archive.tar         # List all files in archive.tar verbosely.
  tar -xf archive.tar          # Extract all files from archive.tar.

So just use tar -cf archiveName.tar folderName.

link|improve this answer
feedback

If you want to compress it, add the -z or -j arguments to the recommendations above.

ssh user@host 'tar -C direcotry -czf archivename.tar.gz files/directory'
link|improve this answer
feedback

If the content you want to archive is in the home directory of the user - it should be:

ssh login_name@hostname 'tar cvf archive-name *'

If you need to navigate somewhere, try this:

ssh login_name@hostname 'cd some-dir;tar cvf archive-name *'
link|improve this answer
feedback

Your Answer

 
or
required, but never shown