Cyber Security · मराठी आवृत्ती
Archives आणि compression: tar, gzip, zip
या page मध्ये
अनेक files एकत्र pack करणं म्हणजे archive; size कमी करणं म्हणजे compression. Tar archive सोबत gzip/xz वापरता येतात. Backup तयार करताना आणि restore करताना दोन्ही समजून घ्या.
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 -c create, -t list, -x extract, -z gzip, -J xz, -v verbose आणि -f archive filename. -C ने extraction directory देता येते. Xz काही data वर लहान archive देऊ शकतो पण अधिक वेळ/resources लागू शकतात.
gzip big.log ने big.log.gz तयार होतो; साध्या वापरात original replace होतो. gunzip ने decompress करतात. Zip/unzip commands साठी packages नसतील तर trusted repository मधून install करा. Existing files वर extract केल्यास overwrite होऊ शकतो; आधी content/path तपासा.
Backup कुठे ठेवायचा?
Backup ransomware आणि चुकांनंतर recovery साठी महत्त्वाचा आहे. पण web root मध्ये site-backup.tar.gz ठेवल्यास तो public download होऊ शकतो. Part 10 मधले directory discovery tools अशा नावांचा शोध घेऊ शकतात. Backups public serving path च्या बाहेर आणि योग्य access restrictions मध्ये ठेवा.
Practice
~/labs चा labs.tar.gz archive करा. Contents list करा आणि /tmp/restore या वेगळ्या directory मध्ये extract करा. Original व restored files तुलना करा.