CentOS] Remote archiving with tar over ssh

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hi James,


> > tar c $(find / -name \*.conf) | ssh host.com "gzip -c > file.tar.gz"
> 
> Thank you very much, this worked.  I have two supplementary 
> questions.  First, what is the significance of the $() construct in 
> bash and how does it interact with tar? Does it take the place of 
> standard input based on its position in the utility call?  

In this command, the $() construct is used to return files via find to the command line for tar. It's most often used to assign variables with the value of returned commands. ie FOO=$(netstat), where by $FOO is now assigned the output of netstat. Since this is a remote command, it's neccessary to do it this way. If you were running this locally only, these two commands would be identical:

tar -cvf foobar.tar `find / -name \*.conf`
tar -cvf foobar.tar $(find / -name \*.conf)


> Second, is there a way to exclude certain file names from matching 
> that otherwise do?  I have tried:
> 
>  $(find / -name /*.conf && !*.so.conf) 

There sure is, but try something like this instead:

tar c $(find / -name \*.conf -not -name \*.so.conf) | ssh host.com "gzip -c > file.tar.gz"


Cheers,
-Joshua

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux