How can I compact directory except folder specific?

2

I need SSH to compress a directory except a specific folder within that directory.

  • folder : / public_html

How can I perform this operation? I made a command that was actually deleting the except files but that's not what I want.

    
asked by anonymous 10.02.2015 / 17:21

2 answers

2

Use the --exclude argument of the tar command:

tar -pczf public_html.tar.gz /public_html/ --exclude "/public_html/wp-content/uploads/Vista"
    
10.02.2015 / 17:24
1

You can use the --exclude parameter of tar to compress everything but the specified directory / file .

Example with bzip2 compression:

tar jcvf arquivo.tar.bz2 --exclude="/public_html/wp-content/uploads/Vista/" /public_html
    
10.02.2015 / 17:25