0

I have a daily rsync script backing up my data on an external hard drive at /mnt/X (root of hard drive). I am using --link-dest to use hard links and avoid duplicating data. I need to move all my daily backups from /mnt/X to /mnt/X/backups without loosing the hard links. Later I will need to change the script to backup in the new dest directory which is /mnt/X/backups and look for previous day backup in the same directory.

How would you suggest me to do the move?

1
  • Look at rsnapshot instead
    – roaima
    Apr 11 '20 at 11:34
1

You don't have to do anything special. Simply,

mv /mnt/X/* to /mnt/X/backups/

(You will get an error about not being able to move backups to itself).

A hard link is basically an inode number. Files that are hard-linked have the same inode number. However you move them around within the same file-system, the inode number does not change. So there is no special action needed.

Try it for yourself with some simple files in /tmp first:

/tmp $ mkdir aa
/tmp $ touch aa/f
/tmp $ ln aa/f aa/g
/tmp $ mkdir aa/new
/tmp $ mv aa/* aa/new
mv: cannot move 'aa/new' to a subdirectory of itself, 'aa/new/new'
/tmp $ ls -il aa/new/
13185910 -rw-r--r-- 2  0 Apr 11 13:32 f
13185910 -rw-r--r-- 2  0 Apr 11 13:32 g

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.