[Solved] rsync + hardlinks to source?

Everything about X, Gnome, KDE, ... and everything running on it

[Solved] rsync + hardlinks to source?

Postby bester69 » 2018-12-29 13:35

Hi,

How can I mirror/sync a target structure files by using hardlink pointing to sourse files?, Ive seen: rsync -H, only replicate hardlinks estructure in target, but doesnt applyhardlinks target to source files.



thanks.
Last edited by bester69 on 2018-12-31 21:13, edited 1 time in total.
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1413
Joined: 2015-04-02 13:15

Re: rsync + hardlinks to source?

Postby xepan » 2018-12-30 00:13

To me it isn't really clear what you mean.
xepan
 
Posts: 89
Joined: 2018-11-28 06:38

Re: rsync + hardlinks to source?

Postby bester69 » 2018-12-30 12:52

xepan wrote:To me it isn't really clear what you mean.

To mirror a directory by using all hardlinks, with rsync. I dont know if we can use rsync in this way.. or we need to use "find -exec cp -larv"
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1413
Joined: 2015-04-02 13:15

Re: rsync + hardlinks to source?

Postby xepan » 2018-12-31 00:38

I never really had the need to look into hardlinks, but as you can do a full system backup with rsync i would assume it can handle it. A quick test seems to confirm it, but i am not too sure:
Code: Select all
$ mkdir source target
$ touch source/foobar
$ ln source/foobar source/l_foobar
$ rsync -auvH source/ target/
sending incremental file list
./
l_foobar
foobar => l_foobar

sent 154 bytes  received 58 bytes  424.00 bytes/sec
total size is 0  speedup is 0.00
$ ls -avi source/
6817024 .  6692928 ..  6817026 foobar  6817026 l_foobar
$ ls -avi target/
6817025 .  6692928 ..  6817027 foobar  6817027 l_foobar
$

Might be what you wanted is that target/l_foobar gets linked to source/foobar? (that was the part i didn't understand, but as said, i don't really have experience with hardlinks at all. I mainly cared for the rsync part of the question, but even after reading the OP back and forth a few times i didn't understand it. You might want to give a real example to make it more easy for the reader - or it is just me being dumb here).

If it is a critical project you could ask in IRC #rsync. The arch wiki has a long article about rsync, but i don't know if it covers such questions too. I only go there to copy and paste the command for a full system backup.

long story short: good luck.
xepan
 
Posts: 89
Joined: 2018-11-28 06:38

Re: rsync + hardlinks to source?

Postby llivv » 2018-12-31 00:55

besides expans' great example above - I was going to suggest similar of running the tests yourself.

check the link man page again for clarification on the differences between hard and soft links
paying attention to
what is linked to, from source in a soft link
and
what is copied from source to target of a hard link.

than run the test to see if rsync behaves like you believe it should.
bester69 wrote:To mirror a directory by using all hardlinks,
can you show an example

or even better several examples of how the hard links are being made -
if the hard links are made with different options in your case?

I'm not following exactly what your asking...
In memory of Ian Ashley Murdock (1973 - 2015) founder of the Debian project.
User avatar
llivv
 
Posts: 5488
Joined: 2007-02-14 18:10
Location: cold storage

Re: rsync + hardlinks to source?

Postby bester69 » 2018-12-31 10:04

llivv wrote:besides expans' great example above - I was going to suggest similar of running the tests yourself.

check the link man page again for clarification on the differences between hard and soft links
paying attention to
what is linked to, from source in a soft link
and
what is copied from source to target of a hard link.

than run the test to see if rsync behaves like you believe it should.
bester69 wrote:To mirror a directory by using all hardlinks,
can you show an example

or even better several examples of how the hard links are being made -
if the hard links are made with different options in your case?

I'm not following exactly what your asking...

I want mirroring a folder with hardlink.

A/file.odt
>>> (mirror to B/; all files created with hardlinks in B target)
B/file.odt

Edit A/file.odt, and then check B/file.odt is updated (rsync -H only sync hardlinks, so I think we cant use rsync with this purpose). It seem the only way to get this is with "find --exec cp -larv"

find A/ -exec cp -larv "{}" B/ \;
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1413
Joined: 2015-04-02 13:15

Re: rsync + hardlinks to source?

Postby xepan » 2018-12-31 11:44

off-topic: I saw it in your other thread already, but there assumed it might be a typo:
I sure never have seen {} in quotes, but as i don't know the name of it, i can't search if that "makes sense".
(you could argue: that i haven't seen it doesn't mean that much, and you would be right).
seems to work, btw, shellcheck also doesn't complain, iirc, so really just chat (you might wanna ask a find-guru what he says about it).
Also not sure: for lots of files one might use + instead of \; ? (i never really understood the difference, again: a find-guru is needed ...).

Now i think: why not simply hardlink all in A/ to B/ ? Or just rsync --update the whole shebang after you edited in directory A/ ?
but, as said, it seems your problem is above me.
xepan
 
Posts: 89
Joined: 2018-11-28 06:38

Re: rsync + hardlinks to source?

Postby bester69 » 2018-12-31 20:05

I saw this.:
http://www.mikerubel.org/computers/rsync_snapshots/

Update (2003.04.23): As of rsync-2.5.6, the --link-dest flag is now standard. Instead of the separate cp -al and rsync lines above, you may now write:

mv backup.0 backup.1
rsync -a --delete --link-dest=../backup.1 source_directory/ backup.0/


The option to do the same as "cp -al" (copy as hardlink) with rsync is using option --link-dest

So This is what i Was looking for:
rsync -aAXv --delete --link-dest=/home/user/source/ source/ target/
(more or less quivalent to this.: find source/ -exec cp -larv "{}" target/ \;)

Example.:
mkdir 1 2
touch 1/popo
rsync -aAXv --delete --link-dest=/home/user/1/ 1/ 2/
echo "test hardlink" > 1/popo
cat 2/popo >> test hardlink

COOL!!
bester69 wrote:You wont change my mind when I know Im right, Im not an ...
User avatar
bester69
 
Posts: 1413
Joined: 2015-04-02 13:15

Re: [Solved] rsync + hardlinks to source?

Postby xepan » 2019-01-01 00:06

still doesn't make any sense to me.
xepan
 
Posts: 89
Joined: 2018-11-28 06:38


Return to Desktop & Multimedia

Who is online

Users browsing this forum: No registered users and 6 guests

fashionable