Discussion:
rsync and link-dest not working
(too old to reply)
William Unruh
2022-11-06 17:14:19 UTC
Permalink
I am trying to copy a backup on a usb hard drive. The usb partition is
ext4 as is the partition I am trying to back up

mount
/dev/nvme0n1p8 on / type ext4 (rw,noatime)
/dev/sda2 on /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca type ext4 (rw,nosuid,nodev,relatime,errors=remount-ro,uhelper=udisks2)

/dev/sda2 is a usb drive. / is an internal ssh drive.

I run
rsync -avxAHXp --link-dest ./crawler-root-aug12-2022 / ./crawler-root-nov6-2022

while on the backup directory on the usb drive (mounted in
/run/media/unruh)
But for example
crawler:0[root]>ls -l crawler-root-*-2022/dead.letter
-rw------- 2 root root 7210272 Dec 12 2021 crawler-root-aug12-2022/dead.letter
-rw------- 1 root root 7210272 Dec 12 2021 crawler-root-nov6-2022/dead.letter

shows that dead.letter was copied over, not hard linked.

diff on the two says there is no difference between the two files, so
they should have been hard linked not copied.

I have also tried with
rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 / ./crawler-root-nov6-2022
but the same thing happens (no hard link)

(Note that the fact that crawler-root-aug12-2022/dead.letter has a hard
link, that is to a previous backup I made. Even if I erase all of crawler-root-nov6-2022
its hard link status remains at 2)

Can anyone offer me a clue as to what could be going wrong?
Aragorn
2022-11-06 17:36:53 UTC
Permalink
Post by William Unruh
I am trying to copy a backup on a usb hard drive. The usb partition is
ext4 as is the partition I am trying to back up
mount
/dev/nvme0n1p8 on / type ext4 (rw,noatime)
/dev/sda2 on /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca
type ext4 (rw,nosuid,nodev,relatime,errors=remount-ro,uhelper=udisks2)
/dev/sda2 is a usb drive. / is an internal ssh drive.
I run
rsync -avxAHXp --link-dest ./crawler-root-aug12-2022 /
./crawler-root-nov6-2022
while on the backup directory on the usb drive (mounted in
/run/media/unruh)
But for example
crawler:0[root]>ls -l crawler-root-*-2022/dead.letter
-rw------- 2 root root 7210272 Dec 12 2021
crawler-root-aug12-2022/dead.letter -rw------- 1 root root 7210272
Dec 12 2021 crawler-root-nov6-2022/dead.letter
shows that dead.letter was copied over, not hard linked.
diff on the two says there is no difference between the two files, so
they should have been hard linked not copied.
I have also tried with
rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 /
./crawler-root-nov6-2022 but the same thing happens (no hard link)
(Note that the fact that crawler-root-aug12-2022/dead.letter has a
hard link, that is to a previous backup I made. Even if I erase all
of crawler-root-nov6-2022 its hard link status remains at 2)
Can anyone offer me a clue as to what could be going wrong?
You forgot the "=". It should have been...

$ rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 / \
./crawler-root-nov6-2022

↑
--
With respect,
= Aragorn =
William Unruh
2022-11-07 01:03:37 UTC
Permalink
....
Post by Aragorn
Post by William Unruh
I have also tried with
rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 /
./crawler-root-nov6-2022 but the same thing happens (no hard link)
(Note that the fact that crawler-root-aug12-2022/dead.letter has a
hard link, that is to a previous backup I made. Even if I erase all
of crawler-root-nov6-2022 its hard link status remains at 2)
Can anyone offer me a clue as to what could be going wrong?
You forgot the "=". It should have been...
$ rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 / \
./crawler-root-nov6-2022
As I said, I tried that.
Post by Aragorn
↑
Daniel65
2022-11-07 08:50:00 UTC
Permalink
Post by William Unruh
....
Post by Aragorn
Post by William Unruh
I have also tried with
rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 /
./crawler-root-nov6-2022 but the same thing happens (no hard link)
(Note that the fact that crawler-root-aug12-2022/dead.letter has a
hard link, that is to a previous backup I made. Even if I erase all
of crawler-root-nov6-2022 its hard link status remains at 2)
Can anyone offer me a clue as to what could be going wrong?
You forgot the "=". It should have been...
$ rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 / \
./crawler-root-nov6-2022
As I said, I tried that.
William, did you notice that the 'rsync' command you posted ended its
first line with *2022 /* and then continued on the next line whereas
Aragon's command had *2022 / \* and then continued on the next line??

Is Aragon's extra *\* important??
--
Daniel
Aragorn
2022-11-07 14:24:56 UTC
Permalink
Post by Daniel65
Post by William Unruh
....
Post by Aragorn
Post by William Unruh
I have also tried with
rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 /
./crawler-root-nov6-2022 but the same thing happens (no hard link)
(Note that the fact that crawler-root-aug12-2022/dead.letter
has a hard link, that is to a previous backup I made. Even if I
erase all of crawler-root-nov6-2022 its hard link status remains
at 2)
Can anyone offer me a clue as to what could be going wrong?
You forgot the "=". It should have been...
$ rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 / \
./crawler-root-nov6-2022
As I said, I tried that.
William, did you notice that the 'rsync' command you posted ended its
first line with *2022 /* and then continued on the next line whereas
Aragon's command had *2022 / \* and then continued on the next line??
Is Aragon's extra *\* important??
I added the backslash because my newsreader wraps the lines at 72
characters, which broke up Bill's command in two lines. The backslash
therefore escapes the newline character.
--
With respect,
= Aragorn =
Daniel65
2022-11-08 09:45:03 UTC
Permalink
Post by Aragorn
Post by Daniel65
Post by William Unruh
....
Post by Aragorn
Post by William Unruh
I have also tried with
rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 /
./crawler-root-nov6-2022 but the same thing happens (no hard link)
(Note that the fact that crawler-root-aug12-2022/dead.letter
has a hard link, that is to a previous backup I made. Even if I
erase all of crawler-root-nov6-2022 its hard link status remains
at 2)
Can anyone offer me a clue as to what could be going wrong?
You forgot the "=". It should have been...
$ rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 / \
./crawler-root-nov6-2022
As I said, I tried that.
William, did you notice that the 'rsync' command you posted ended its
first line with *2022 /* and then continued on the next line whereas
Aragon's command had *2022 / \* and then continued on the next line??
Is Aragon's extra *\* important??
I added the backslash because my newsreader wraps the lines at 72
characters, which broke up Bill's command in two lines. The backslash
therefore escapes the newline character.
Somewhere, waaay back in my mind, I had thought about that "continues on
next line" situation ..... but, maybe, I was expecting William to be
aware of that, too. Maybe he was composing in a very wide window so it
just slipped his mind!
--
Daniel
William Unruh
2022-11-07 14:25:37 UTC
Permalink
Post by Daniel65
Post by William Unruh
....
Post by Aragorn
Post by William Unruh
I have also tried with
rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 /
./crawler-root-nov6-2022 but the same thing happens (no hard link)
(Note that the fact that crawler-root-aug12-2022/dead.letter has a
hard link, that is to a previous backup I made. Even if I erase all
of crawler-root-nov6-2022 its hard link status remains at 2)
Can anyone offer me a clue as to what could be going wrong?
You forgot the "=". It should have been...
$ rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 / \
./crawler-root-nov6-2022
As I said, I tried that.
William, did you notice that the 'rsync' command you posted ended its
first line with *2022 /* and then continued on the next line whereas
Aragon's command had *2022 / \* and then continued on the next line??
Is Aragon's extra *\* important??
My linebreak cam about because the posting software put in a linebreak
into a long line. What was actually run had no line break.
Daniel65
2022-11-08 09:45:40 UTC
Permalink
Post by William Unruh
Post by Daniel65
Post by William Unruh
....
Post by Aragorn
Post by William Unruh
I have also tried with
rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 /
./crawler-root-nov6-2022 but the same thing happens (no hard link)
(Note that the fact that crawler-root-aug12-2022/dead.letter has a
hard link, that is to a previous backup I made. Even if I erase all
of crawler-root-nov6-2022 its hard link status remains at 2)
Can anyone offer me a clue as to what could be going wrong?
You forgot the "=". It should have been...
$ rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 / \
./crawler-root-nov6-2022
As I said, I tried that.
William, did you notice that the 'rsync' command you posted ended its
first line with *2022 /* and then continued on the next line whereas
Aragon's command had *2022 / \* and then continued on the next line??
Is Aragon's extra *\* important??
My linebreak cam about because the posting software put in a linebreak
into a long line. What was actually run had no line break.
;-)
--
Daniel
Richard Kettlewell
2022-11-06 18:21:29 UTC
Permalink
Post by William Unruh
I am trying to copy a backup on a usb hard drive. The usb partition is
ext4 as is the partition I am trying to back up
mount
/dev/nvme0n1p8 on / type ext4 (rw,noatime)
/dev/sda2 on /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca
type ext4 (rw,nosuid,nodev,relatime,errors=remount-ro,uhelper=udisks2)
/dev/sda2 is a usb drive. / is an internal ssh drive.
I run
rsync -avxAHXp --link-dest ./crawler-root-aug12-2022 / ./crawler-root-nov6-2022
while on the backup directory on the usb drive (mounted in
/run/media/unruh)
But for example
crawler:0[root]>ls -l crawler-root-*-2022/dead.letter
-rw------- 2 root root 7210272 Dec 12 2021 crawler-root-aug12-2022/dead.letter
-rw------- 1 root root 7210272 Dec 12 2021 crawler-root-nov6-2022/dead.letter
shows that dead.letter was copied over, not hard linked.
diff on the two says there is no difference between the two files, so
they should have been hard linked not copied.
I have also tried with
rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 / ./crawler-root-nov6-2022
but the same thing happens (no hard link)
(Note that the fact that crawler-root-aug12-2022/dead.letter has a hard
link, that is to a previous backup I made. Even if I erase all of crawler-root-nov6-2022
its hard link status remains at 2)
Can anyone offer me a clue as to what could be going wrong?
Perhaps there is some difference not visible in ‘ls -l’. What is the
output of:

stat crawler-root-*-2022/dead.letter /dead.letter
sha256sum crawler-root-*-2022/dead.letter /dead.letter
--
http://www.greenend.org.uk/rjk/
Carlos E.R.
2022-11-06 18:38:29 UTC
Permalink
Post by William Unruh
I am trying to copy a backup on a usb hard drive. The usb partition is
ext4 as is the partition I am trying to back up
mount
/dev/nvme0n1p8 on / type ext4 (rw,noatime)
/dev/sda2 on /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca type ext4 (rw,nosuid,nodev,relatime,errors=remount-ro,uhelper=udisks2)
/dev/sda2 is a usb drive. / is an internal ssh drive.
I run
rsync -avxAHXp --link-dest ./crawler-root-aug12-2022 / ./crawler-root-nov6-2022
Doesn't the source include the destination?
--
Cheers, Carlos.
William Unruh
2022-11-07 01:06:36 UTC
Permalink
Post by Carlos E.R.
Post by William Unruh
I am trying to copy a backup on a usb hard drive. The usb partition is
ext4 as is the partition I am trying to back up
mount
/dev/nvme0n1p8 on / type ext4 (rw,noatime)
/dev/sda2 on /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca type ext4 (rw,nosuid,nodev,relatime,errors=remount-ro,uhelper=udisks2)
/dev/sda2 is a usb drive. / is an internal ssh drive.
I run
rsync -avxAHXp --link-dest ./crawler-root-aug12-2022 / ./crawler-root-nov6-2022
Doesn't the source include the destination?
No, the pwd was /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca
which is on the usb drive, not in / (see the -x in rsync)
David W. Hodgins
2022-11-06 17:43:23 UTC
Permalink
Post by William Unruh
I am trying to copy a backup on a usb hard drive. The usb partition is
ext4 as is the partition I am trying to back up
mount
/dev/nvme0n1p8 on / type ext4 (rw,noatime)
/dev/sda2 on /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca type ext4 (rw,nosuid,nodev,relatime,errors=remount-ro,uhelper=udisks2)
/dev/sda2 is a usb drive. / is an internal ssh drive.
I run
rsync -avxAHXp --link-dest ./crawler-root-aug12-2022 / ./crawler-root-nov6-2022
while on the backup directory on the usb drive (mounted in
/run/media/unruh)
But for example
crawler:0[root]>ls -l crawler-root-*-2022/dead.letter
-rw------- 2 root root 7210272 Dec 12 2021 crawler-root-aug12-2022/dead.letter
-rw------- 1 root root 7210272 Dec 12 2021 crawler-root-nov6-2022/dead.letter
shows that dead.letter was copied over, not hard linked.
diff on the two says there is no difference between the two files, so
they should have been hard linked not copied.
I have also tried with
rsync -avxAHXp --link-dest=./crawler-root-aug12-2022 / ./crawler-root-nov6-2022
but the same thing happens (no hard link)
(Note that the fact that crawler-root-aug12-2022/dead.letter has a hard
link, that is to a previous backup I made. Even if I erase all of crawler-root-nov6-2022
its hard link status remains at 2)
Can anyone offer me a clue as to what could be going wrong?
Please show the output of "ls -il crawler-root-*-2022/dead.letter" to confirm
which inode each is pointing to.

Regards, Dave Hodgins
William Unruh
2022-11-07 01:09:22 UTC
Permalink
Post by David W. Hodgins
Post by William Unruh
(Note that the fact that crawler-root-aug12-2022/dead.letter has a hard
link, that is to a previous backup I made. Even if I erase all of crawler-root-nov6-2022
its hard link status remains at 2)
Can anyone offer me a clue as to what could be going wrong?
Please show the output of "ls -il crawler-root-*-2022/dead.letter" to confirm
which inode each is pointing to.
Regards, Dave Hodgins
crawler:0[unruh]>ls -il /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca/crawler-*-2022/dead.letter
52429120 -rw------- 2 root root 7210272 Dec 12 2021 /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca/crawler-root-aug12-2022/dead.letter
49152355 -rw------- 1 root root 7210272 Dec 12 2021 /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca/crawler-root-nov6-2022/dead.letter
David W. Hodgins
2022-11-07 05:59:30 UTC
Permalink
Post by William Unruh
Post by David W. Hodgins
Post by William Unruh
(Note that the fact that crawler-root-aug12-2022/dead.letter has a hard
link, that is to a previous backup I made. Even if I erase all of crawler-root-nov6-2022
its hard link status remains at 2)
Can anyone offer me a clue as to what could be going wrong?
Please show the output of "ls -il crawler-root-*-2022/dead.letter" to confirm
which inode each is pointing to.
Regards, Dave Hodgins
crawler:0[unruh]>ls -il /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca/crawler-*-2022/dead.letter
52429120 -rw------- 2 root root 7210272 Dec 12 2021 /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca/crawler-root-aug12-2022/dead.letter
49152355 -rw------- 1 root root 7210272 Dec 12 2021 /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca/crawler-root-nov6-2022/dead.letter
Figured it out ...
[***@x3 /tmp]# ls -li source/* dest*/*
270 -rw-r--r-- 1 dave dave 5 Nov 7 00:41 dest1/datafile
269 -rw-r--r-- 1 dave dave 5 Nov 7 00:41 source/datafile
[***@x3 /tmp]# rsync -avxAHXp --link-dest=/tmp/dest1/ ./source/ /tmp/dest2/
sending incremental file list
./

sent 94 bytes received 19 bytes 226.00 bytes/sec
total size is 5 speedup is 0.04
[***@x3 /tmp]# ls -li source/* dest*/*
270 -rw-r--r-- 2 dave dave 5 Nov 7 00:41 dest1/datafile
270 -rw-r--r-- 2 dave dave 5 Nov 7 00:41 dest2/datafile
269 -rw-r--r-- 1 dave dave 5 Nov 7 00:41 source/datafile

The --link-dest= must be an absolute path, not a relative one. No idea why,
but using ./dest2 instead of /tmp/dest2 in my testing does not work.

Regards, Dave Hodgins
William Unruh
2022-11-07 14:29:46 UTC
Permalink
Post by David W. Hodgins
Post by William Unruh
Post by David W. Hodgins
Post by William Unruh
(Note that the fact that crawler-root-aug12-2022/dead.letter has a hard
link, that is to a previous backup I made. Even if I erase all of crawler-root-nov6-2022
its hard link status remains at 2)
Can anyone offer me a clue as to what could be going wrong?
Please show the output of "ls -il crawler-root-*-2022/dead.letter" to confirm
which inode each is pointing to.
Regards, Dave Hodgins
crawler:0[unruh]>ls -il /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca/crawler-*-2022/dead.letter
52429120 -rw------- 2 root root 7210272 Dec 12 2021 /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca/crawler-root-aug12-2022/dead.letter
49152355 -rw------- 1 root root 7210272 Dec 12 2021 /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca/crawler-root-nov6-2022/dead.letter
Figured it out ...
270 -rw-r--r-- 1 dave dave 5 Nov 7 00:41 dest1/datafile
269 -rw-r--r-- 1 dave dave 5 Nov 7 00:41 source/datafile
sending incremental file list
./
sent 94 bytes received 19 bytes 226.00 bytes/sec
total size is 5 speedup is 0.04
270 -rw-r--r-- 2 dave dave 5 Nov 7 00:41 dest1/datafile
270 -rw-r--r-- 2 dave dave 5 Nov 7 00:41 dest2/datafile
269 -rw-r--r-- 1 dave dave 5 Nov 7 00:41 source/datafile
The --link-dest= must be an absolute path, not a relative one. No idea why,
but using ./dest2 instead of /tmp/dest2 in my testing does not work.
OK, I will try that. Weird. It needs to be documented in the man page.

Thanks for tracking this down.
Post by David W. Hodgins
Regards, Dave Hodgins
William Unruh
2022-11-07 14:55:23 UTC
Permalink
Post by William Unruh
Post by David W. Hodgins
Post by William Unruh
Post by David W. Hodgins
Post by William Unruh
(Note that the fact that crawler-root-aug12-2022/dead.letter has a hard
link, that is to a previous backup I made. Even if I erase all of crawler-root-nov6-2022
its hard link status remains at 2)
Can anyone offer me a clue as to what could be going wrong?
Please show the output of "ls -il crawler-root-*-2022/dead.letter" to confirm
which inode each is pointing to.
Regards, Dave Hodgins
crawler:0[unruh]>ls -il /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca/crawler-*-2022/dead.letter
52429120 -rw------- 2 root root 7210272 Dec 12 2021 /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca/crawler-root-aug12-2022/dead.letter
49152355 -rw------- 1 root root 7210272 Dec 12 2021 /run/media/unruh/ab7c8370-e9d4-495f-a9fa-a18e803dd9ca/crawler-root-nov6-2022/dead.letter
Figured it out ...
270 -rw-r--r-- 1 dave dave 5 Nov 7 00:41 dest1/datafile
269 -rw-r--r-- 1 dave dave 5 Nov 7 00:41 source/datafile
sending incremental file list
./
sent 94 bytes received 19 bytes 226.00 bytes/sec
total size is 5 speedup is 0.04
270 -rw-r--r-- 2 dave dave 5 Nov 7 00:41 dest1/datafile
270 -rw-r--r-- 2 dave dave 5 Nov 7 00:41 dest2/datafile
269 -rw-r--r-- 1 dave dave 5 Nov 7 00:41 source/datafile
The --link-dest= must be an absolute path, not a relative one. No idea why,
but using ./dest2 instead of /tmp/dest2 in my testing does not work.
I assume ./dest1 or /tmp/dest1 for the --link-dest
Post by William Unruh
OK, I will try that. Weird. It needs to be documented in the man page.
Thanks for tracking this down.
Oops. It seems it is documented. From the man page:

If DIR is a relative path, it is relative to the destination directory. See also --compare-dest
and --copy-dest.

I guess it should have been ../dest1 or as you say, /tmp/dest1
David W. Hodgins
2022-11-07 17:20:13 UTC
Permalink
Post by William Unruh
I guess it should have been ../dest1 or as you say, /tmp/dest1
Or perhaps slightly easier to read ...
rsync -avxAHXp --link-dest="$PWD"/dest1/ ./source/ ./dest2/

Regards, Dave Hodgins
Loading...