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.
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:
The above command restores the /home/wahib/Personal/Contents.doc
files from the archive.
If you just want to see what files are in the backup volume, Use the --list or -t option:
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