4

system("tar -czf #{RAILS_ROOT}/tmp/export-result #{RAILS_ROOT}/tmp/export")

When I decompress the resulting file I get

app/c3ec2057-7d3a-40d9-9a9d-d5c3fe3ffd6f/home/tmp/export/and_the_files

I would like to just get:

export_result/and_the_files

How do I change my TAR call to accomplish this?

solution:

system("tar -czf #{RAILS_ROOT}/tmp/export.tgz --directory=#{RAILS_ROOT}/tmp export/")

Nerian
  • 1,327

2 Answers2

3

This is how you do it,

tar cfz target.tgz --directory=TARGET_DIR subdir_list

In your case it would look like,

tar cfz target.tgz --directory=app/c3ec2057-7d3a-40d9-9a9d-d5c3fe3ffd6f/home/tmp export/
nik
  • 57,042
1

Change to #{RAILS_ROOT} before compression and don't specify it in the source files.