Using tar to backup a Linux System
  Jul 01, 2010

You can easily tar up a Linux box and extract the files on a Linux partition (some version of ext). This can be great for making an image of a dying hard-drive or putting a hard-drive in another box, mounting it, and then making a backup (great if you need to mount read-only).

The following creates an archive, gzips the archive for greater compression, verbosely prints to the screen what is being backed up, preserves all permissions, and stores it in a file "device" /path/to/archive.tar.gz.

History lesson: most implementations of tar still default to using a tape device as output for the file stream!

  1. # tar -pczvf /path/to/archive.tar.gz
  2. > --directory=/
  3. > --exclude=proc --exclude=sys --exclude=dev/pts
  4. > .

To decompress the archive to the current working directory:

  1. # tar -pxzvf archive.tar.gz



Post a New Comment

Name

Message

Security
Code

        (case insensitive & space between words)