Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




33.4. Restore files with tar

More important than performing regular backups is having them available when we need to recover important files! In this section, we will discuss methods for restoring files, which have been backed up with tar command.

The following command will restore all files from the full-backup-Day-Month-Year.tar archive, which is an example backup of our home directory created from the example tar commands shown above.
[[email protected]] /# cd /
[[email protected]] /# tar xpf /dev/st0/full-backup-Day-Month-Year.tar
The above command extracts all files contained in the compressed archive, preserving original file ownership and permissions.

  • The x option stands for extract.

  • The p option preserve permissions; file protection information will be remembered.

  • The f option states that the very next argument will be the name of the archive file or device.

If you do not need to restore all the files contained in the archive, you can specify one or more files that you wish to restore: To specify one or more files that you wish to restore, use the following command:
[[email protected]]# cd /
[[email protected]]# tar xpf /dev/st0/full-backup-Day-Month-Year.tar \
 home/wahib/Personal/Contents.doc home/quota.user
The above command restores the /home/wahib/Personal/Contents.doc and /home/quota.user files from the archive.

If you just want to see what files are in the backup volume, Use the --list or -t option:
[[email protected]] /# tar tf /dev/st0


If you have files on your system set with the immutable bit, using the chattr command, these files will not be remembered with the immutable bit from your restored backup. You must reset it immutable with the command chattr +i after the backup is completed.


Test the ability to recover: Dont forget to test the ability to recover from backups, for many system administrators, recovering a file from a backup is an uncommon activity. This step assures that if you need to recover a file, the tools and processes will work. Performing this test periodically will help you to discover problems with the backup procedures so you can correct them before losing data. Some backup restoration software does not accurately recover the correct file protection and file ownership controls. Check the attributes of restored files to ensure they are being set correctly. Periodically test to ensure that you can perform a full system recovery from your backups.

Further documentation, for more details, there is man page you can read:


- The GNU version of the tar archiving utility

  Published under the terms of the Open Publication License Design by Interspire