Archiving and Compression
====================================================================================
gzip
====================================================================================
tar (.tar) - Tape Archive
Take multiple files and compress them into a single file.
-c -create archive
-f -filename
-x -extract
-z -compress/decompress
-f -filename
Creating an archive (uncompressed)
tar -cf archivename.tar filestoarchive
Creating an archive (compressed)
tar -czf archivename.tar.gz filestoarchive
Extracting a tar archive (compressed)
tar -xzf archivename.tar.gz
Extracting a tar archive (uncompressed)
tar -xf archivename.tar
====================================================================================
DD - Convert and copy
Full disk backup
dd if=/dev/sda of=/pathtobackupfile.img
By default, dd will take the backup 1 block at a time - meaning it can take a while. We can add the 'bs' option to specify how much data dd should copy at a time.
dd if=/dev/sda of=/pathtobackupfile.img bs=1M
For sensitive copies, we can add the conv=sync flag to have dd compare the original data and the copy for 100% accuracy - this will take a lot longer.
dd if=/dev/sda of=/pathtobackupfile.img bs=1M conv=sync
Compression
We can also pipe the dd output into gzip for compression.
dd if=/dev/sda bs=1M | gzip -o > pathtobackupfile.gz
To uncompress:
gunzip pathtobackupfile.gz | dd of=/dev/sdc bs=1M
====================================================================================
xz (.xz) -
cpio (.io) -
No Comments