I have a filesystem with a series of date stamped archival backups of another filesystem. The backup uses hardlinks to copy only the delta between consecutive archival instances. The drive has had some data corruption and I am working to replace it, however some files are corrupted and not copied successfully. I have other copies of the damaged files to restore with, but I do not know a good way to replace the damaged file within the structure of hardlinks.
01/01 02/01 03/01 -file1 >> -file1 x Added in 01/01, deleted by 03/01 -file2 >> -file2 >> -file2 Added in 01/01, never deleted -file3 >> -file3 Added in 02/01, never deleted
In the above case there is one data store for
file2, with two (or three depending how you count) hardlinks. If the base file data is corrupted, how can I use my backup file to restore
file2 and retain its hardlinks?
- The original data lives on one physical device in a folder structure.
- The backups/archive copies are of the complete folder structure held on the original data device (1.). They are consecutive in time, deduplicated and hardlinked between themselves on the backup device.
- The copy I will be restoring from is a third device used to store images of the backup device for long-term cold storage.
- The errors have occurred on the backup device listed in (2.). I would like to have the corrupted files on this backup device restored from either the original location (1.) or the cold-storage device (3.), within the structure of the backups/archive.
The backup logic:
5.1. Find last date/time stamped backup folder
<last backup folder>on device (2.)
5.2. Make new empty backup folder
<new folder>with current date/time stamp.
5.3. Make hardlinked copy of files in last backup folder:
cp -al <last backup folder> <new folder>
5.4. Make copy of data from
<source data>from (1.) to new backup folder, over hardlinked backup folder made in (5.3.):
rsync -azH --delete <source data> <new folder>
Having attempted to use the advice from one answer, the corrupt file at the destination cannot be inplace replaced. Clearly the destination at that location has a hard fault of some kind and the replacement data needs to go to a new physical location on disk.