Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

[Solved] rsync + hardlinks to source?

Graphical Environments, Managers, Multimedia & Desktop questions.
Post Reply
Message
Author
User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

[Solved] rsync + hardlinks to source?

#1 Post by bester69 »

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:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

xepan
Posts: 89
Joined: 2018-11-28 06:38

Re: rsync + hardlinks to source?

#2 Post by xepan »

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

User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Re: rsync + hardlinks to source?

#3 Post by bester69 »

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:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

xepan
Posts: 89
Joined: 2018-11-28 06:38

Re: rsync + hardlinks to source?

#4 Post by xepan »

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.

User avatar
llivv
Posts: 5340
Joined: 2007-02-14 18:10
Location: cold storage

Re: rsync + hardlinks to source?

#5 Post by llivv »

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
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Re: rsync + hardlinks to source?

#6 Post by bester69 »

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:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

xepan
Posts: 89
Joined: 2018-11-28 06:38

Re: rsync + hardlinks to source?

#7 Post by xepan »

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.

User avatar
bester69
Posts: 2072
Joined: 2015-04-02 13:15
Has thanked: 24 times
Been thanked: 14 times

Re: rsync + hardlinks to source?

#8 Post by bester69 »

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:STOP 2030 globalists demons, keep the fight for humanity freedom against NWO...

xepan
Posts: 89
Joined: 2018-11-28 06:38

Re: [Solved] rsync + hardlinks to source?

#9 Post by xepan »

still doesn't make any sense to me.

Post Reply