compression - How to create a tar file (tar.gz) file with a specific directory tree -


i'm trying backup directory tree has structure:

/home/joe/projects/goodie/binary_program /home/joe/projects/goodie/image.png /home/joe/projects/goodie/sound.ogg /home/joe/projects/goodie/license.txt 

i want create archive following structure:

goodie-2015_04_09-15_34/binary_program goodie-2015_04_09-15_34/image.png goodie-2015_04_09-15_34/sound.ogg goodie-2015_04_09-15_34/license.txt 

i know how create date/time stamp label, don't know how create tree structure inside of tar file..any ideas?

gnu tar has --transform option runs sed on file names (or file paths) prior putting them archive.

source=/home/joe/projects/goodie name=goodie-2015_04_09-15_34  tar cvzf $name.tar.gz $source/* --transform "s@^$source@$name@" 

Popular posts from this blog