How to compact directory except a specific folder via SSH with zip command?

0

I have to compress all files and directories from the public_html directory except var that is over 60GB. How can I perform this operation via SSH with command zip ? I saw some forms with different commands tar and others but I need to execute this operation with command zip .

  

I just want to compress without the var and not delete it from the hosting.

    
asked by anonymous 20.04.2016 / 13:21

2 answers

3

Looking at man zip found option --exclude or -x , I believe this is exactly what you need.

-x files
       --exclude files
              Explicitly exclude the specified files, as in:

                     zip -r foo foo -x \*.o

              which  will  include  the  contents  of foo in foo.zip while excluding all the files that end in .o.  The backslash avoids the shell filename substitution, so that the name
              matching is performed by zip at all directory levels.

              Also possible:

                     zip -r foo foo [email protected]

              which will include the contents of foo in foo.zip while excluding all the files that match the patterns in the file exclude.lst.

              The long option forms of the above are

                     zip -r foo foo --exclude \*.o

              and

                     zip -r foo foo --exclude @exclude.lst

              Multiple patterns can be specified, as in:

                     zip -r foo foo -x \*.o \*.c

              If there is no space between -x and the pattern, just one value is assumed (no list):

                     zip -r foo foo -x\*.o

              See -i for more on include and exclude.
    
20.04.2016 / 13:40
1

You will have to execute the command remotely, then:

ssh [email protected] -p 2255 'zip backup.zip /public_html --exclude var'

The command will ask for the user's password and you will have your file compressed.

Ps .: Obviously it is necessary to adapt the command to your scenario, in case o -p 2255 is the connection port to SSH

    
20.04.2016 / 13:50