# 4.5 tar, gzip आणि zip ने archive करूया

Source: https://ravindrabagale.com/mr/aws/ch04-linux-advanced-commands/4-5-archiving-and-compression-tar-gzip-zip.html
Language: mr (Marathi with English technical terms)

Website backup, logs transfer किंवा WordPress archive extract करण्यासाठी tar उपयोगी. c create, x extract, z gzip, v verbose, f file हे flags लक्षात ठेवा.

tar -czvf site-backup.tar.gz /var/www/html      # create gzip archive (c=create z=gzip v=verbose f=file)
tar -tzvf site-backup.tar.gz                    # list contents
mkdir -p /tmp/restore
tar -xzvf site-backup.tar.gz -C /tmp/restore    # extract into a folder
tar -cJvf logs.tar.xz /var/log/nginx            # xz compression (smaller, slower)
gzip big.log            # -> big.log.gz        gunzip big.log.gz
zip -r site.zip mysite/                         # install package 'zip' if missing
unzip site.zip -d /var/www/html/                # install package 'unzip' if missing

tar.gz आधी list करा, मग वेगळ्या restore folder मध्ये extract करा. xz compression अनेकदा लहान file तयार करतो पण वेळ जास्त लागू शकतो. gzip/gunzip file compress/decompress करतात. zip/unzip packages वेगळे लागू शकतात.

Lab

tar -czvf ~/mauli-site.tar.gz ~/labs/mauli, मग tar -tzvf ~/mauli-site.tar.gz. mkdir -p /tmp/restore करून tar -xzvf ~/mauli-site.tar.gz -C /tmp/restore. ls -R /tmp/restore ने पाहा.

रवींद्र बागले यांची tip

Extract करण्याआधी tar -tzvf ने contents पाहा. f नंतर लगेच archive नाव देण्याची सवय ठेवा — tar -czvf archive.tar.gz folder — म्हणजे option parsing चा गोंधळ टळतो.
