Learn about Centmin Mod LEMP Stack today
Register Now

Sysadmin What is the best way to zip an entire directory?

Discussion in 'System Administration' started by Itworx4me, Apr 1, 2019.

  1. Itworx4me

    Itworx4me Member

    220
    21
    18
    Mar 14, 2017
    Ratings:
    +35
    Local Time:
    2:03 AM
    Nginx 1.17.X
    MariaDB 10.3.X
    What is the best way to zip an entire directory from command line?

    Thanks,
    Itworx4me
     
  2. Itworx4me

    Itworx4me Member

    220
    21
    18
    Mar 14, 2017
    Ratings:
    +35
    Local Time:
    2:03 AM
    Nginx 1.17.X
    MariaDB 10.3.X
    Maybe tar is a better way?
     
  3. Jimmy

    Jimmy Well-Known Member

    1,704
    365
    83
    Oct 24, 2015
    East Coast USA
    Ratings:
    +923
    Local Time:
    5:03 AM
    1.17.x
    MariaDB 10.3.x
    Google search... Itdoesn'tworx4u?
     
  4. eva2000

    eva2000 Administrator Staff Member

    44,743
    10,200
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,809
    Local Time:
    7:03 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    yup tar command best as you can tell tar to preserve permissions
     
  5. eva2000

    eva2000 Administrator Staff Member

    44,743
    10,200
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,809
    Local Time:
    7:03 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    yup tar command best as you can tell tar to preserve permissions
     
  6. Itworx4me

    Itworx4me Member

    220
    21
    18
    Mar 14, 2017
    Ratings:
    +35
    Local Time:
    2:03 AM
    Nginx 1.17.X
    MariaDB 10.3.X
    Code (Text):
    tar -czf files_$(date +%d.%m.%y).tar.gz /path/to/copy

    Is -czf sufficient or would you add more to it?
     
  7. eva2000

    eva2000 Administrator Staff Member

    44,743
    10,200
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +15,809
    Local Time:
    7:03 PM
    Nginx 1.17.x
    MariaDB 5.5/10.x