May the source be with you, but remember the KISS principle ;-)
Contents Bulletin Scripting in shell and Perl Network troubleshooting History Humor

Tar options for bare metal recovery

News Disaster Recovery Recommended Links Unix tape archiver (Tar) Perl Backup Scripts Disk Backup and Cloning Alternatives to Norton Ghost Cloning systems, disks and partitions
Baseliners Relax-and-Recover Dump and restore Gzip Unix cpio Relax-and-Recover Backing Up And Restoring Linux With SystemImager
dd Remote backups using dd rsync Recovery of lost files using DD Mount a partition from dd disk image Dell DRAc and VFLASH Partimage
logrotate rsync HP Data Protector dd Sysadmin Horror Stories Humor Etc


There is a lot conflicting information about what options to use for creation of recovery tarball. Here is what Relax-and-Recover uses (relax and recover is just fancy envelope for tar)

# save everything except /mnt and /proc.

time tar cvpPzf $TARBALL  -X /exclude_dirs / 
If you have everything in one partition you can use option --one-file-system and explicitly exclude pseudo-directories such as /proc /sys
time tar cvpPzf $TARBALL  --one-file-system   --exclude /mnt --exclude /proc exclude /sys 


Warning: Exclude actually  specifies not a file path by a "basic" (DOS style) regular expression for the file(s) ot directories.

 Excluding Some Files

To avoid operating on files whose names match a particular pattern, use the `--exclude' or `--exclude-from' options.

Causes tar to ignore files that match the pattern.

The `--exclude=pattern' option prevents any file or member whose name matches the shell wildcard (pattern) from being operated on. For example, to create an archive with all the contents of the directory `src' except for files whose names end in `.o', use the command `tar -cf src.tar --exclude='*.o' src'.

You may give multiple `--exclude' options.

`-X file'
Causes tar to ignore files that match the patterns listed in file.

Use the `--exclude-from' option to read a list of patterns, one per line, from file; tar will ignore files matching those patterns. Thus if tar is called as `tar -c -X foo .' and the file `foo' contains a single line `*.o', no files whose names end in `.o' will be added to the archive.

Notice, that lines from file are read verbatim. One of the frequent errors is leaving some extra whitespace after a file name, which is difficult to catch using text editors.

However, empty lines are OK.

When archiving directories that are under some version control system (VCS), it is often convenient to read exclusion patterns from this VCS' ignore files (e.g. `.cvsignore', `.gitignore', etc.) The following options provide such possibility:

Before archiving a directory, see if it contains any of the following files: `cvsignore', `.gitignore', `.bzrignore', or `.hgignore'. If so, read ignore patterns from these files.

The patterns are treated much as the corresponding VCS would treat them, i.e.:

Contains shell-style globbing patterns that apply only to the directory where this file resides. No comments are allowed in the file. Empty lines are ignored.
Contains shell-style globbing patterns. Applies to the directory where `.gitfile' is located and all its subdirectories.

Any line beginning with a `#' is a comment. Backslash escapes the comment character.

Contains shell globbing-patterns and regular expressions (if prefixed with `RE:'(16). Patterns affect the directory and all its subdirectories.

Any line beginning with a `#' is a comment.

Contains posix regular expressions(17). The line `syntax: glob' switches to shell globbing patterns. The line `syntax: regexp' switches back. Comments begin with a `#'. Patterns affect the directory and all its subdirectories.
Before dumping a directory, tar checks if it contains file. If so, exclusion patterns are read from this file. The patterns affect only the directory itself.
Same as `--exclude-ignore', except that the patterns read affect both the directory where file resides and all its subdirectories.
Exclude files and directories used by following version control systems: `CVS', `RCS', `SCCS', `SVN', `Arch', `Bazaar', `Mercurial', and `Darcs'.

As of version 1.29, the following files are excluded:

  • `CVS/', and everything under it
  • `RCS/', and everything under it
  • `SCCS/', and everything under it
  • `.git/', and everything under it
  • `.gitignore'
  • `.gitmodules'
  • `.gitattributes'
  • `.cvsignore'
  • `.svn/', and everything under it
  • `.arch-ids/', and everything under it
  • `{arch}/', and everything under it
  • `=meta-update'
  • `=update'
  • `.bzr'
  • `.bzrignore'
  • `.bzrtags'
  • `.hg'
  • `.hgignore'
  • `.hgrags'
  • `_darcs'
Exclude backup and lock files. This option causes exclusion of files that match the following shell globbing patterns:

When creating an archive, the `--exclude-caches' option family causes tar to exclude all directories that contain a cache directory tag. A cache directory tag is a short file with the well-known name `CACHEDIR.TAG' and having a standard header specified in Various applications write cache directory tags into directories they use to hold regenerable, non-precious data, so that such data can be more easily excluded from backups.

There are three `exclude-caches' options, each providing a different exclusion semantics:

Do not archive the contents of the directory, but archive the directory itself and the `CACHEDIR.TAG' file.
Do not archive the contents of the directory, nor the `CACHEDIR.TAG' file, archive only the directory itself.
Omit directories containing `CACHEDIR.TAG' file entirely.

Another option family, `--exclude-tag', provides a generalization of this concept. It takes a single argument, a file name to look for. Any directory that contains this file will be excluded from the dump. Similarly to `exclude-caches', there are three options in this option family:

Do not dump the contents of the directory, but dump the directory itself and the file.
Do not dump the contents of the directory, nor the file, archive only the directory itself.
Omit directories containing file file entirely.

Multiple `--exclude-tag*' options can be given.

For example, given this directory:

$ find dir

The `--exclude-tag' will produce the following:

$ tar -cf archive.tar --exclude-tag=tagfile -v dir
tar: dir/folk/: contains a cache directory tag tagfile;
  contents not dumped

Both the `dir/folk' directory and its tagfile are preserved in the archive, however the rest of files in this directory are not.

Now, using the `--exclude-tag-under' option will exclude `tagfile' from the dump, while still preserving the directory itself, as shown in this example:

$ tar -cf archive.tar --exclude-tag-under=tagfile -v dir
./tar: dir/folk/: contains a cache directory tag tagfile;
  contents not dumped

Finally, using `--exclude-tag-all' omits the `dir/folk' directory entirely:

$ tar -cf archive.tar --exclude-tag-all=tagfile -v dir
./tar: dir/folk/: contains a cache directory tag tagfile;
  directory not dumped
Problems with Using the exclude Options   

[ < ][ > ]  [ << ][ Up ][ >> ]        [Top][Contents][Index][ ? ]

Problems with Using the exclude Options

Some users find `exclude' options confusing. Here are some common pitfalls:


Exclude File

tar has the ability to ignore specified files and directories contained in a special file. the localtion of the file is specified with option -X.  The syntax is one definition per line. tar also has the capability to understand regular expressions (regexps). For example:

# Not old backups                                                              
# Not temporary files                                                          

# Not the cache for pacman


see BackupYourSystem-TAR - Community Help Wiki

Backup Script

Success of bare metal recovery using tar archive depends on the correctness of your options.  Here is a basic script that can do it and provides a couple checks. You'll need to modify this script to define your backup location, and exclude file (if you have one), and then just run this command after you've chrooted and mounted all your partitions.

# full system backup

# Backup destination

# Labels for backup name
date=$(date "+%F")

# Exclude file location
prog=${0##*/} # Program name from filename

# Check if chrooted prompt.
echo -n "First chroot from a LiveCD.  Are you ready to backup? (y/n): "
read executeback

# Check if exclude file exists
if [ ! -f $exclude_file ]; then
  echo -n "No exclude file exists, continue? (y/n): "
  read continue
  if [ $continue == "n" ]; then exit; fi

if [ $executeback = "y" ]; then
  # -p and --xattrs store all permissions and extended attributes.
  # Without both of these, many programs will stop working!
  # It is safe to remove the verbose (-v) flag. If you are using a
  # slow terminal, this can greatly speed up the backup process.
  tar --exclude-from=$exclude_file --xattrs -czpvf $backupfile /


First stage restoration

Run you kickstart file with you ISO disk to get a base system.

Second Stage Restoration

To restore the test computer:

[root@tester ~]# restore.all

If you used tar for your backup and restoration, and used the -k (keep old files, don't overwrite) option, you will see a lot of this:

tar: usr/sbin/rpcinfo: Could not create file:  File exists
tar: usr/sbin/zdump: Could not create file:  File exists
tar: usr/sbin/zic: Could not create file:  File exists
tar: usr/sbin/ab: Could not create file:  File exists
This is normal, as tar is refusing to overwrite files you restored during the first stage of restoration.

Just to be paranoid, run LILO after you perform your restoration. I doubt it is necessary, but if it is necessary, it's a lot easier than the alternative. You will notice I have it in my script, restore.all (see Listing 3).

Listing 3. restore.all Script

Now reboot. On the way down, you will see a lot of error messages, such as “no such pid.” This is a normal part of the process. The shutdown code is using the pid files from dæmons that were running when the backup was made to shut down dæmons that were not started on the last boot. Of course there's no such pid.

Your system should come up normally, with a lot fewer errors than it had before. The acid test of how well your restore works on an RPM based system is to verify all packages:

rpm -Va

Some files, such as configuration and log files, will have changed in the normal course of things, and you should be able to mentally filter those out of the report.

If you took my advice earlier and keep RPM metadata as a normal part of your backup process, you should be able to diff the two files, thereby speeding up this step considerably.

You should be up and running. It is time to test your applications, especially those that run as dæmons. The more sophisticated the application, the more testing you may need to do. If you have remote users, disable them from using the system, or make it “read only” while you test it. This is especially important for databases, to prevent making any corruption or data loss worse than it already might be.

If you normally boot to X, and disabled it above, test X before you re-enable it. Re-enable it by changing that one line in /etc/inittab back to: id:5:initdefault:

You should now be ready to rock and roll—and for some Aspirin and a couch.


SanDisk FIT USB drives can be as large as 128 GB.  

"FIT" form factor  almost does not protrude from the USB port. There is a small (orange in case of SanDisk) indicator light and I kind of like it. When it is writing or reading, the light will blink. They are supposed to be plugged in and seldom pulled out, or pulled out fairly rarely. Perfect for local backup of OS. 
Bar form factor protrude one inch or so. Which in many case is acceptable but still carry some risks. 



USB 2.0


Top Visited
Past week
Past month


Old News ;-)

Recommended Links

Softpanorama hot topic of the month

Softpanorama Recommended


GNU tar 1.29 5. Performing Backups and Restoring Files

Full System Backup with tar - ArchWiki

Backing up Files with Tar - O'Reilly Media outdate (2002)

Full Hard-Drive Backup with Linux Tar

Bare-metal server restore using tar The source for Linux information (2005)

8.2.6. Restoration Issues

Linux & Windows Bare Metal Recovery - Backup Central

Linux RedHat Bare Metal Restore on dissimilar system

Bare Metal Recovery Linux Journal outdated


FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available in our efforts to advance understanding of environmental, political, human rights, economic, democracy, scientific, and social justice issues, etc. We believe this constitutes a 'fair use' of any such copyrighted material as provided for in section 107 of the US Copyright Law. In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit exclusivly for research and educational purposes.   If you wish to use copyrighted material from this site for purposes of your own that go beyond 'fair use', you must obtain permission from the copyright owner. 

ABUSE: IPs or network segments from which we detect a stream of probes might be blocked for no less then 90 days. Multiple types of probes increase this period.  


Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy


War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes


Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law


Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least

Copyright © 1996-2016 by Dr. Nikolai Bezroukov. was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License.

The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to make a contribution, supporting development of this site and speed up access. In case is down you can use the at


The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

Last modified: July, 14, 2017