About hard links to files and directories on UNIX/Linux

Article:HOWTO33683  |  Created: 2010-10-28  |  Updated: 2011-03-10  |  Article URL http://www.symantec.com/docs/HOWTO33683
Article Type
How To


Environment

Subject


About hard links to files and directories on UNIX/Linux

A hard link is a directory entry for a file. Every file can be considered to have at least one hard link. A hard link differs from a symbolic link in that a hard link is not a pointer to another file. A hard link is two directory entries that point to the same inode number.

If the backup selection list includes hard-linked files, the data is backed up only once during a backup. NetBackup uses the first file name reference that is found in the directory structure. If a subsequent file name reference is found, it is backed up as a link to the name of the first file. Backup up only the link means that only one backup copy of the data is created, regardless of the number of hard links. Any hard link to the data works.

On most UNIX systems, only the root user can create a hard link to a directory. Some systems do not permit hard links, and many vendors recommend that these links be avoided. NetBackup does not back up and restore hard-linked directories in the same manner as files.

Hard-linked files and hard-linked directories are different in the following ways:

  • During a backup, if NetBackup encounters hard-linked directories, the directories are backed up once for each hard link.

  • During a restore, NetBackup restores multiple copies of the hard-linked directory contents if the directories do not already exist on the disk. If the directories exist on disk, NetBackup restores the contents multiple times to the same disk location.

On NTFS volumes or on UNIX systems, each file can have multiple hard links. Therefore, a single file can appear in many directories (or even in the same directory with different names). A volume serial number (VSN) and a File Index indicate the actual, unique file on the volume. Collectively, the VSN and File Index are referred to as the file ID.

During a backup, if the backup selection list includes hard-linked files, the data is backed up only once. NetBackup uses the first file name reference that is found in the directory structure. If a subsequent file name reference is found, the reference is backed up as a link to the name of the first file. To back up subsequent references means that only one backup copy of the data is created, regardless of the number of multiple hard links.

If all hard-link references are restored, the hard-linked files continue to point to the same ID as the other files to which they are linked. However, if all the hard links are not restored, you can encounter anomalies as shown in the following examples.

Example 1: Restoring Link2 and Link3

Assume that three hard links point to the same data. During a backup of Link2 and Link3, Link2 is encountered first and backed up. Then Link3 is backed up as a link to Link2. The three files are all hard-linked to the same data.

Figure: Example of hard links to the same data

Example of hard links to the same data

The original copies of Link2 and Link3 are backed up to tape, then deleted. Only Link1 is left on the disk.

Figure: Example of hard links backed up to tape and disk

Example of hard links backed up to tape and disk

During a subsequent restore, Link2 and Link3 are restored. The restored files, however, do not point to the same file ID as Link1. Instead, they are assigned a new file ID or inode number and the data is written to a new place on the disk. The data in the new location is an exact copy of what is in Link1. The duplication occurs because the backup does not associate Link2 and L3 with Link1.

Figure: Example of restored hard links

Example of restored hard links

Example 2: Restoring Link3

Assume that this time you attempt to restore only Link3. However, NetBackup cannot link Link3 to Link2 because Link2 does not exist. The restore can complete only if it can link to Link2. A secondary restore request to the NetBackup server automatically restores Link2, which contains the data. Link2 can now be successfully restored.

See Backup Selections tab on UNIX/Linux

See Adding backup selections to a policy on UNIX/Linux

See How to reduce backup time on UNIX/Linux

See Verifying the Backup Selections list on UNIX/Linux

See Pathname rules for Windows client backups on UNIX/Linux

See Pathname rules for Windows disk image (raw) backups on UNIX/Linux

See Pathname rules for Windows registry backups on UNIX/Linux

See Pathname rules for UNIX client backups on UNIX/Linux

See Pathname rules for NetWare NonTarget clients on UNIX/Linux

See Pathname rules for NetWare Target clients on UNIX/Linux

See Pathname rules for the clients that run extension products on UNIX/Linux

See About the directives on the Backup Selections list

See Files that are excluded from backups by default on UNIX/Linux


Legacy ID



v42176710_v46435089


Article URL http://www.symantec.com/docs/HOWTO33683


Terms of use for this information are found in Legal Notices