I don't think you can do what you want here. The problem with your approach is that tar
deals in files and directory trees, which you're not providing it with commands such as this:
$ echo test | tar -cf test.tar /dev/sdtin
Even when you attempt to "wrap" your strings in temporary files using subshells such as this:
$ tar -cf test.tar <(echo test)
You can see your content is still being TAR'ed up using these temporary file descriptors:
$ tar tvf test.tar
lr-x------ vagrant/vagrant 0 2018-08-04 23:52 dev/fd/63 -> pipe:[102734]
If you're intent is just to compress strings, you need to get them into a file context. So you'd need to do something like this:
$ echo "test" > somefile && tar -cf /tmp/test.tar somefile
You can see the file's present inside of the TAR file:
$ tar tvf /tmp/test.tar
-rw-rw-r-- vagrant/vagrant 5 2018-08-05 00:00 somefile
Replicating data using tar
Most that have been working with Unix for several years will likely have seen this pattern:
$ (cd /; tar cf - .)|(cd /mnt/newroot; tar pxvf -)
I used to use this all the time to replicate data from one location to another. You can use this over SSH as well. Other methods are discussed in this U&L Q&A titled: clone root directory tree using busybox.
Backing up /
There's also this method if you're intent is to back up the entier HDD:
$ sudo tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz --one-file-system /
References
pv /dev/sda | tar -cSf disk.tar /dev/stdin
– Daffy Aug 5 '18 at 3:41echo test ¦ tar -cf test.tar -
– Rui F Ribeiro Aug 5 '18 at 3:46tar
d streams. unix.stackexchange.com/questions/151009/… – mikeserv Aug 5 '18 at 4:10shitar
might not be what you want, but you may get a clue there. i tried to touch on basic format requisites enough for me to understand later. – mikeserv Aug 5 '18 at 4:13