public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* When only rsync will do .. or maybe not
@ 2022-10-12 10:55 Fergus Daly
  2022-10-14 13:36 ` Cyrille Lefevre
  2022-10-22 14:39 ` Andrey Repin
  0 siblings, 2 replies; 4+ messages in thread
From: Fergus Daly @ 2022-10-12 10:55 UTC (permalink / raw)
  To: 'cygwin@cygwin.com'; +Cc: Fergus Daly

Requirement: to move some selected files and folders under /folder1/ to /folder2/, preserving full pathnames.

Using cp with the switch --parents (taking care over syntax and importantly location $PWD) it is possible to _copy_ the
Required content across from /folder1/ to /folder2/ but there does not seem to be a matching switch for mv that would
achieve the same purpose.

One solution would be (i) to copy the required content to /folder2/ and then (ii) delete the identical content under /folder1/;
but this is expensive (one might not even have the disk space to do it) and it seems seriously unsatisfactory and not without risk
to have to copy folders and files (possibly huge) when all one wants to do is to change the {pathname} to them.

Question 1
Would the command (or something like it, again with care over syntax and $PWD)
$ rsync -axuv --progress {pathto}/folder1/{content} {pathto}/folder2/   
do the trick? Or is the very existence of the switch
$ rsync -axuv --remove-source-files --progress {pathto}/folder1/{content} {pathto}/folder2/
indicative that here too the "move" is achieved through a two-stage "copy-then-delete" operation?

Question 2
If rsync can provide a genuine "move" capability then is installing the rsync package adequate to the purpose;
or would librsync-devel and/or librsync2 packages need to be installed also?

Question 3
If not rsync, is there any operation for which "move" can be achieved without involving "copy-then-delete"? 

Thank you for any assistance.


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: When only rsync will do .. or maybe not
  2022-10-12 10:55 When only rsync will do .. or maybe not Fergus Daly
@ 2022-10-14 13:36 ` Cyrille Lefevre
  2022-10-14 15:35   ` Lemke, Michael  SF/HZA-ZE2E
  2022-10-22 14:39 ` Andrey Repin
  1 sibling, 1 reply; 4+ messages in thread
From: Cyrille Lefevre @ 2022-10-14 13:36 UTC (permalink / raw)
  To: cygwin

Le 12/10/2022 à 12:55, Fergus Daly a écrit :
> Requirement: to move some selected files and folders under /folder1/ to /folder2/, preserving full pathnames.
> 
> Using cp with the switch --parents (taking care over syntax and importantly location $PWD) it is possible to _copy_ the
> Required content across from /folder1/ to /folder2/ but there does not seem to be a matching switch for mv that would
> achieve the same purpose.
> 
> One solution would be (i) to copy the required content to /folder2/ and then (ii) delete the identical content under /folder1/;
> but this is expensive (one might not even have the disk space to do it) and it seems seriously unsatisfactory and not without risk
> to have to copy folders and files (possibly huge) when all one wants to do is to change the {pathname} to them.
> 
> Question 1
> Would the command (or something like it, again with care over syntax and $PWD)
> $ rsync -axuv --progress {pathto}/folder1/{content} {pathto}/folder2/
> do the trick? Or is the very existence of the switch
> $ rsync -axuv --remove-source-files --progress {pathto}/folder1/{content} {pathto}/folder2/
> indicative that here too the "move" is achieved through a two-stage "copy-then-delete" operation?
> 
> Question 2
> If rsync can provide a genuine "move" capability then is installing the rsync package adequate to the purpose;
> or would librsync-devel and/or librsync2 packages need to be installed also?
> 
> Question 3
> If not rsync, is there any operation for which "move" can be achieved without involving "copy-then-delete"?
> 
> Thank you for any assistance.
> 
> 

Hi,

how about find /source | cpio -pdml /target
alternative, cp -alu --parent /source /target
then purge /source

Regards,

/me
-- 
mailto:Cyrille.Lefevre-lists@laposte.net


^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: When only rsync will do .. or maybe not
  2022-10-14 13:36 ` Cyrille Lefevre
@ 2022-10-14 15:35   ` Lemke, Michael  SF/HZA-ZE2E
  0 siblings, 0 replies; 4+ messages in thread
From: Lemke, Michael  SF/HZA-ZE2E @ 2022-10-14 15:35 UTC (permalink / raw)
  To: cygwin

On October 14, 2022 3:36 PM Cyrille Lefevre wrote:
>Le 12/10/2022 à 12:55, Fergus Daly a écrit :
>> Requirement: to move some selected files and folders under /folder1/ to /folder2/, preserving full pathnames.
>> 
>> Using cp with the switch --parents (taking care over syntax and importantly location $PWD) it is possible to _copy_ the
>> Required content across from /folder1/ to /folder2/ but there does not seem to be a matching switch for mv that would
>> achieve the same purpose.
>> 
>> One solution would be (i) to copy the required content to /folder2/ and then (ii) delete the identical content under /folder1/;
>> but this is expensive (one might not even have the disk space to do it) and it seems seriously unsatisfactory and not without risk
>> to have to copy folders and files (possibly huge) when all one wants to do is to change the {pathname} to them.
>> 
>> Question 1
>> Would the command (or something like it, again with care over syntax and $PWD)
>> $ rsync -axuv --progress {pathto}/folder1/{content} {pathto}/folder2/
>> do the trick? Or is the very existence of the switch
>> $ rsync -axuv --remove-source-files --progress {pathto}/folder1/{content} {pathto}/folder2/
>> indicative that here too the "move" is achieved through a two-stage "copy-then-delete" operation?
>> 
>> Question 2
>> If rsync can provide a genuine "move" capability then is installing the rsync package adequate to the purpose;
>> or would librsync-devel and/or librsync2 packages need to be installed also?
>> 
>> Question 3
>> If not rsync, is there any operation for which "move" can be achieved without involving "copy-then-delete"?
>> 
>> Thank you for any assistance.
>> 
>> 
>
>Hi,
>
>how about find /source | cpio -pdml /target
>alternative, cp -alu --parent /source /target
>then purge /source
>

Another idea: instead of copies create hardlinks in /folder2 (ln without -s) and then use 'find /folder1 -links 2 ...' to remove the originals. Exact syntax left as an exercise to the reader. Method is a little fragile if hardlinks exist in /folder1. Use with caution. Additional space required is just the directory entries.

Michael

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: When only rsync will do .. or maybe not
  2022-10-12 10:55 When only rsync will do .. or maybe not Fergus Daly
  2022-10-14 13:36 ` Cyrille Lefevre
@ 2022-10-22 14:39 ` Andrey Repin
  1 sibling, 0 replies; 4+ messages in thread
From: Andrey Repin @ 2022-10-22 14:39 UTC (permalink / raw)
  To: Fergus Daly, cygwin

Greetings, Fergus Daly!

> Requirement: to move some selected files and folders under /folder1/ to /folder2/, preserving full pathnames.

Full pathname would include the /folder1 making the requirement impossible
from the start.
If, on the other hand, you want to preserve directory structure, then a simple

    cd /f1; find . -xdev -type d -exec mkdir -p "/f2/{}" ';' -o -type f -exec mv '{}' "/f2/{}" ';'

will do.

> One solution would be (i) to copy the required content to /folder2/ and
> then (ii) delete the identical content under /folder1/;
> but this is expensive (one might not even have the disk space to do it) and
> it seems seriously unsatisfactory and not without risk
> to have to copy folders and files (possibly huge) when all one wants to do is to change the {pathname} to them.

`cp --reflink=always` will take care of duplicated content.
Do note that paths must be relative. cp has an issue detecting "same volume"
and failing or falling back to simple copy.

> Question 1
> Would the command (or something like it, again with care over syntax and $PWD)
> $ rsync -axuv --progress {pathto}/folder1/{content} {pathto}/folder2/   
> do the trick? Or is the very existence of the switch
> $ rsync -axuv --remove-source-files --progress {pathto}/folder1/{content} {pathto}/folder2/
> indicative that here too the "move" is achieved through a two-stage "copy-then-delete" operation?

> Question 2
> If rsync can provide a genuine "move" capability then is installing the
> rsync package adequate to the purpose;
> or would librsync-devel and/or librsync2 packages need to be installed also?

No, not the purpose of rsync.

> Question 3
> If not rsync, is there any operation for which "move" can be achieved
> without involving "copy-then-delete"? 

Yep.
See above.


-- 
With best regards,
Andrey Repin
Saturday, October 22, 2022 11:56:05

Sorry for my terrible english...


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-10-22 14:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-12 10:55 When only rsync will do .. or maybe not Fergus Daly
2022-10-14 13:36 ` Cyrille Lefevre
2022-10-14 15:35   ` Lemke, Michael  SF/HZA-ZE2E
2022-10-22 14:39 ` Andrey Repin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).