Chapter 4: Linux Advanced Commands
4.5 Archiving and compression: tar, gzip, zip
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