LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   tar files from multiple locations into a tarball preserving location paths (https://www.linuxquestions.org/questions/linux-newbie-8/tar-files-from-multiple-locations-into-a-tarball-preserving-location-paths-818994/)

Siljrath 07-09-2010 07:15 PM

tar files from multiple locations into a tarball preserving location paths
 
i reckon i could do this with a whole load of &&s and tar appends, but i'd much rather just paste in a list of file paths to a single command. ... i suppose i could achieve similar with a complex "mv" addition to the command, but then i'd lose the very important original locations.

attempts have either lead to multiple files (like when i tried just lzma alone) or error messages when tarring.



what i was trying on my mock-up test files:
Code:

g@usbgeneray:~$ lzma -zk9 /home/g/testzone/marglepeeps /home/g/testzone/om /home/g/testzone/mop.lzma
lzma: /home/g/testzone/mop.lzma: doesn't exist or is not a regular file
g@usbgeneray:~$ man tar
g@usbgeneray:~$ tar -c /home/g/testzone/marglepeeps /home/g/testzone/om /home/g/testzone/mop.tar
tar: Removing leading `/' from member names
tar: /home/g/testzone/mop.tar: Cannot stat: No such file or directory
home/g/testzone/marglepeeps0000644000175000017500000000004611415726164013603 0ustar  ggmarglemargle... pEEp! pEEp! pEEEEEEp!
home/g/testzone/om0000644000175000017500000000002611415726244011707 0ustar  ggommmmmmmmmmmmmmmmmmm

tar: Exiting with failure status due to previous errors
g@usbgeneray:~$ man tar
g@usbgeneray:~$ tar -c /home/g/testzone/mop
tar: Removing leading `/' from member names
tar: /home/g/testzone/mop: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors

i've a feeling i'm going to be shown how silly i'm being and how simple an issue this is.

(and yeah, i did search for it for a while, but failed.)




so in my test example, i want to end up with the files "marglepeeps" and "om" in the same "mop.tar.lzma" file, even if i were to have one of marglepeeps or om, start from a distant location.

when i get this, i hope to include a list of config files into such a command, so i can transfer/backup these configs for use on other machines (and my archiso overlay folder) after a simple extraction.

Tinkster 07-10-2010 12:27 AM

If you want to create a tar the name of the tar comes before
the directories you want to tar up ...
Code:

tar -cvzf /home/g/testzone/mop.tar.gz /home/g/testzone/marglepeeps /home/g/testzone/om

Cheers,
Tink

grail 07-10-2010 01:23 AM

Also, assuming you have the correct compression application installed, the following works well:
Code:

tar acf /home/g/testzone/mop.tar.XXX /home/g/testzone/marglepeeps /home/g/testzone/om
Replace XXX with any of the following - gz, bz2, lzma, xz, and so on


All times are GMT -5. The time now is 02:22 PM.