Unix Advanced [Electronic resources]

Chris Herborth

نسخه متنی -صفحه : 115/ 31
نمايش فراداده

l xmlns="http://www.w3.org/1999/l">

  • Backing Up and Restoring Data

    If you've worked with computers for any length of time, you've probably discovered why making regular backups is important. Specifically, if you haven't backed up your data, you're going to lose it.

    To back up data using tar:

    To restore data using tar:

    • tar -xpzvf archive.tar.gz

      Where archive.tar.gz is the name of an existing archive created with tar. This extracts the files and directories in archive.tar.gz into the current directory.

      The -xpzvf options are, in order: extract the contents of an archive, preserve ownership and permissions, read compressed archives, be verbose, and read the archive data from the file specified by the next argument.

    To back up data using dd:

    • dd bs=1M if=in-path |  gzip > out-path.gz
      

      This dumps in-path (which can be a file or a device) through gzip, one mega byte at a time. The gzip command compresses the data, which is then stored in out-path.gz.

      Using dd this way, you can make an exact backup of a device, such as a disk partition.

    To restore data using dd:

    • gzcat in-path.gz |  dd bs=1M of=out-path
      

      This decompresses in-path.gz and sends it through dd. The dd command writes the data to out-path, one megabyte at a time.