How to back up and restore UNIX/LINUX files with hardlinks.

  • Modified Date:
  • Article ID:000039143


How to back up and restore UNIX/LINUX files with hardlinks.


A Hard Link is just another name for a file or in practice two directory entries that associate two files with each other and which point to the same inode.
The inode is a structure that maintains all file information and which is related to the kernel.
The information in the inode is organized in a table that is created when the file system is created.
The  inode contains 40 or more fields of information about each file.
You cannot have Hardlinks across disk partitions.

Hardlinks are created with the command ln.
SYNOPSIS (See Figure 1)
Figure 1
You can have multiple directory entries (hardlinks) pointing to a file, but there is only one inode.

The number of links can be determined with ls -l. (See Figure 2)
Figure 2 
To also return the inode ID in the output of this command, the argument should include an i : ls -li.

When you back up a file that contains a hard link to another file, Backup Exec writes both the link information and the data file to tape.

When you restore a file that contains hardlink information, Backup Exec will also restore its actual hardlink(s).

If you have two files that are hard-linked together, both files must be backed up to retain the original hardlinks. (See Figure 3)
Figure 3

If you have two files that are hardlinked together and one of them is deleted and needs to be restored, you must restore both files in order to re-establish their hard-links.
The one exception to this procedure occurs if you backup two files that are hard-linked together, and then break the connection between them on the target server. The two files then contain separate data files. If you restore the two files from the Backup Exec server, Backup Exec respects the current file system and does not restore the hard links.

Problems can occur if you backup only one file of a hard-linked pair. For example, files TEST1 and TEST2 contain a hard link to each other. You backup TEST1 and then edit TEST2. If you restore TEST1, the changes you made to TEST2 are lost.

To ensure that hard-linked files remain synchronized, always backup all files that have hard links to each other at the same time, and restore those same files together as shown in figure 3 above.  

Terms of use for this information are found in Legal Notices.



Did this article answer your question or resolve your issue?


Did this article save you the trouble of contacting technical support?


How can we make this article more helpful?

Email Address (Optional)