Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some directories, I want to pack into a tgz archive:


The archive should have the following structure:


Do I have to copy the migration tool into /home/stofl/myproject/ (or create a symlink) or is there another way?


The archive could be compressed with gzip later. So maybe there is a way to append the directory to the tar archive with --append, but I didn't find a way to tell tar to use a different name.

share|improve this question
up vote 3 down vote accepted

As the archive should have relative paths (migrations/ source/ my_migration_tool/) there would have to be an archive made from /home/stofl/myproject.

As you mention you could append a directory to the tar archive (tar only permits appending for non-gzipped archives). But this would not rename the 3rd directory to my_migration_source:

cd /home/stofl/myproject
tar cvf myprojects.tar migrations source
# appends contents of tool to archive
tar -rv --file /home/stofl/myproject/myprojects.tar tool 

The easiest option I think would be to use a symbolic link-:

cd /home/stofl/myprojec 
ln -s my_migration_tool /path/to/my/migration/tool/source/
# tar H option to follow symbolic links
tar cvfH myprojects.tar migrations source my_migration_tool
share|improve this answer
Yes thank you. I think I'll do that (but the option is h, not H, I think). I found an --xfrom parameter, but thats a bit too much for me now to find the right expression (if there is one). – stofl Mar 26 '13 at 11:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.