Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian User (http://www.linux-archive.org/debian-user/)
-   -   rsync issue (http://www.linux-archive.org/debian-user/426139-rsync-issue.html)

Rodolfo Medina 09-12-2010 04:30 PM

rsync issue
 
Hi to all Debian users.

In rsync manual I coudn't find a solution to what I want. I wish to copy all
my home directory into another machine with the --delete option, but:

1) I dont't want hidden files, i.e.: `.*' to be copied;

2) on the other hand, there are some symlinks, beginning with `.', that I want
to be copied.

The --exclude option won't help.

>From my home directory, if I do:

$ rsync -vrtul --delete * 192.168.0.2:/home/rodolfo

, hidden files that are in `~/' are not copied at all nor the --delete option
applies to files that are in `~/', so it's not good; from /home, if I do:

$ rsync -vrtul --delete rodolfo 192.168.0.2:/home

, everything is copied, also system hidden directories and files, which I don't
want.

Please help with this issue.
Thanks for any help
Rodolfo


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 87eicyrkjg.fsf@gmail.com">http://lists.debian.org/87eicyrkjg.fsf@gmail.com

Rob Owens 09-12-2010 05:20 PM

rsync issue
 
On Sun, Sep 12, 2010 at 06:30:59PM +0200, Rodolfo Medina wrote:
> Hi to all Debian users.
>
> In rsync manual I coudn't find a solution to what I want. I wish to copy all
> my home directory into another machine with the --delete option, but:
>
> 1) I dont't want hidden files, i.e.: `.*' to be copied;
>
> 2) on the other hand, there are some symlinks, beginning with `.', that I want
> to be copied.
>
> The --exclude option won't help.
>
> >From my home directory, if I do:
>
> $ rsync -vrtul --delete * 192.168.0.2:/home/rodolfo
>
> , hidden files that are in `~/' are not copied at all nor the --delete option
> applies to files that are in `~/', so it's not good; from /home, if I do:
>
> $ rsync -vrtul --delete rodolfo 192.168.0.2:/home
>
> , everything is copied, also system hidden directories and files, which I don't
> want.
>
Would it be ok to copy everything, and then delete the hidden files and
directories afterwards? I know you can tell the 'find' command to
discriminate between files, directories, and symbolic links by using the
'-type' switch. Maybe something like this would work (test it first,
because I haven't):

find /home/rodolpho/ -maxdepth 1 -iname ".*" -type f -exec rm {} ;
find /home/rodolpho/ -maxdepth 1 -iname ".*" -type d -exec rm -r {} ;

These commands find all the hidden files and directories (but not
symlinks) in your home directory (but not subdirectories) and deletes
them.

-Rob


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20100912172027.GC29852@aurora.owens.net">http://lists.debian.org/20100912172027.GC29852@aurora.owens.net

Rodolfo Medina 09-12-2010 06:01 PM

rsync issue
 
Rodolfo Medina <rodolfo.medina@gmail.com> writes:

> In rsync manual I coudn't find a solution to what I want. I wish to copy all
> my home directory into another machine with the --delete option, but:
>
> 1) I dont't want hidden files, i.e.: `.*' to be copied;
>
> 2) on the other hand, there are some symlinks, beginning with `.', that I
> want to be copied.
>
> The --exclude option won't help.
>
> From my home directory, if I do:
>
> $ rsync -vrtul --delete * 192.168.0.2:/home/rodolfo
>
> , hidden files that are in `~/' are not copied at all nor the --delete option
> applies to files that are in `~/', so it's not good; from /home, if I do:
>
> $ rsync -vrtul --delete rodolfo 192.168.0.2:/home
>
> , everything is copied, also system hidden directories and files, which I
> don't want.
>
> Please help with this issue.
> Thanks for any help


Sorry, I made a mistake: I mean, I want hidden files to be copied, except than
those in `~/': of those, i.e. of the hidden files in `~/', I just want the
symlinks to be copied.

Rodolfo


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 87r5gyq1sz.fsf@gmail.com">http://lists.debian.org/87r5gyq1sz.fsf@gmail.com

Rob Owens 09-12-2010 08:27 PM

rsync issue
 
On Sun, Sep 12, 2010 at 08:01:00PM +0200, Rodolfo Medina wrote:
> Rodolfo Medina <rodolfo.medina@gmail.com> writes:
>
> > In rsync manual I coudn't find a solution to what I want. I wish to copy all
> > my home directory into another machine with the --delete option, but:
> >
> > 1) I dont't want hidden files, i.e.: `.*' to be copied;
> >
> > 2) on the other hand, there are some symlinks, beginning with `.', that I
> > want to be copied.
> >
> > The --exclude option won't help.
> >
> > From my home directory, if I do:
> >
> > $ rsync -vrtul --delete * 192.168.0.2:/home/rodolfo
> >
> > , hidden files that are in `~/' are not copied at all nor the --delete option
> > applies to files that are in `~/', so it's not good; from /home, if I do:
> >
> > $ rsync -vrtul --delete rodolfo 192.168.0.2:/home
> >
> > , everything is copied, also system hidden directories and files, which I
> > don't want.
> >
> > Please help with this issue.
> > Thanks for any help
>
>
> Sorry, I made a mistake: I mean, I want hidden files to be copied, except than
> those in `~/': of those, i.e. of the hidden files in `~/', I just want the
> symlinks to be copied.
>
My previous suggestion still applies. Rsync everything, then delete
what you don't want by using the find command.

-Rob


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20100912202705.GB32270@aurora.owens.net">http://lists.debian.org/20100912202705.GB32270@aurora.owens.net

09-13-2010 01:13 AM

rsync issue
 
>> On Sun, 12 Sep 2010 18:30:59 +0200,
>> Rodolfo Medina <rodolfo.medina@gmail.com> said:

R> I wish to copy all my home directory into another machine with the
R> --delete option, but:
R> 1) I don't want hidden files, i.e.: `.*' to be copied;
R> 2) there are some symlinks, beginning with `.', that I want to be copied.

Instead of copying everything and deleting what you don't want, why not
make a list of the files you want copied and have rsync use that instead?
Something like this:

list=/tmp/list$$ # or use mktemp
cd $HOME

# Ignore hidden files and "." directory...
find . -print | egrep -v '^(./.|.$)' > $list

# ...but keep symlinks starting with a dot.
find . -type l -name '.*' -print >> $list

rsync --files-from=$list [other rsync options, destination, etc]
rm $list

You can add any other filtering you might want after the last "find",
you *know* exactly what files are being synced, and you can store that
list someplace in case there's ever a question of why something did (or
didn't) get copied.

--
Karl Vogel I don't speak for the USAF or my company
I have never hated a man enough to give his diamonds back. --Zsa Zsa Gabor


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 20100913011305.475ABBF53@kev.msw.wpafb.af.mil">htt p://lists.debian.org/20100913011305.475ABBF53@kev.msw.wpafb.af.mil

Rodolfo Medina 09-17-2010 01:07 PM

rsync issue
 
Rodolfo Medina <rodolfo.medina@gmail.com> writes:

>> In rsync manual I coudn't find a solution to what I want. I wish to copy
>> all my home directory into another machine with the --delete option, but:
>>
>> 1) I dont't want hidden files, i.e.: `.*' to be copied;
>>
>> 2) on the other hand, there are some symlinks, beginning with `.', that I
>> want to be copied.
>>
>> The --exclude option won't help.
>>
>> From my home directory, if I do:
>>
>> $ rsync -vrtul --delete * 192.168.0.2:/home/rodolfo
>>
>> , hidden files that are in `~/' are not copied at all nor the --delete
>> option applies to files that are in `~/', so it's not good; from /home, if I
>> do:
>>
>> $ rsync -vrtul --delete rodolfo 192.168.0.2:/home
>>
>> , everything is copied, also system hidden directories and files, which I
>> don't want.
>
>
> I mean, I want hidden files to be copied, except than
> those in `~/': of those, i.e. of the hidden files in `~/', I just want the
> symlinks to be copied.


Thanks to Rob and Karl for their help. The following seems to work:

$ rsync -vrtul --delete --exclude='rodolfo/.*' rodolfo 192.168.0.2:/home

, and I'll create the symlinks by hand. Maybe there's a better solution: I
wish the `delete' option worked also for files and not only for directories,
but in rsync manual couldn't find that.

Rodolfo


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 87hbhoo6wx.fsf@gmail.com">http://lists.debian.org/87hbhoo6wx.fsf@gmail.com

"Jesús M. Navarro" 09-18-2010 03:03 AM

rsync issue
 
Hi, Rodolfo:

On Friday 17 September 2010 15:07:10 Rodolfo Medina wrote:
> Rodolfo Medina <rodolfo.medina@gmail.com> writes:
> >> In rsync manual I coudn't find a solution to what I want. I wish to
> >> copy all my home directory into another machine with the --delete
> >> option, but:
> >>
> >> 1) I dont't want hidden files, i.e.: `.*' to be copied;
> >>
> >> 2) on the other hand, there are some symlinks, beginning with `.', that
> >> I want to be copied.

[...]

> Thanks to Rob and Karl for their help. The following seems to work:
>
> $ rsync -vrtul --delete --exclude='rodolfo/.*' rodolfo 192.168.0.2:/home
>
> , and I'll create the symlinks by hand. Maybe there's a better solution: I
> wish the `delete' option worked also for files and not only for
> directories, but in rsync manual couldn't find that.

Recheck. --delete certainly works on files. Your problem is you can't rely
on object names in order to know what has to be copied or not, since the name
of both the hidden files and the symlinks check against the same pattern.

Since you have a pattern problem, you may build a component list and then
apply it as a filter (see the "filters" section from rsync's man page).

Since you want to copy everything but top level hidden files I'd try something
like this two-step procedure (next command is a single line):

1) find /path/to/rodolfo -maxdepth 1 -type
f -name '.*' -fprint /path/to/filterfile

Then within /path/to/filterfile there should be the list of hidden files you
want to ignore.

2) After that, the rsync step should do the trick, kindof (next command is a
single line) :
rsync -a --exclude-from=/path/to/filterfile /path/to/rodolfo/
remoteuser@remotehost:/path/to/rodolfo

I didn't test the above commands so there might be minor flaws you should
check but I think you get the idea.

Cheers.


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 201009180503.54771.jesus.navarro@undominio.net">ht tp://lists.debian.org/201009180503.54771.jesus.navarro@undominio.net

Rodolfo Medina 09-19-2010 08:25 AM

rsync issue
 
Rodolfo Medina <rodolfo.medina@gmail.com> writes:

>>> In rsync manual I coudn't find a solution to what I want. I wish to copy
>>> all my home directory into another machine with the --delete option, but:
>>>
>>> 1) I dont't want hidden files, i.e.: `.*' to be copied;
>>>
>>> 2) on the other hand, there are some symlinks, beginning with `.', that I
>>> want to be copied.
>>>
>>> The --exclude option won't help.
>>>
>>> From my home directory, if I do:
>>>
>>> $ rsync -vrtul --delete * 192.168.0.2:/home/rodolfo
>>>
>>> , hidden files that are in `~/' are not copied at all nor the --delete
>>> option applies to files that are in `~/', so it's not good; from /home, if
>>> I do:
>>>
>>> $ rsync -vrtul --delete rodolfo 192.168.0.2:/home
>>>
>>> , everything is copied, also system hidden directories and files, which I
>>> don't want.
>>
>>
>> I mean, I want hidden files to be copied, except than
>> those in `~/': of those, i.e. of the hidden files in `~/', I just want the
>> symlinks to be copied.


I think it's better to create the symlinks by hand, as they can be different
when going from a system to another. Then the following is good for me:

$ cd
$ rsync -vrtul --delete --exclude='.*' . 192.168.0.2:/home/rodolfo

The main issue here is that I had to replace `*' with `.' as the list of files
to be transferred.

Thanks for anyone's help.
Rodolfo


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 87pqwa16no.fsf@gmail.com">http://lists.debian.org/87pqwa16no.fsf@gmail.com

Rodolfo Medina 09-19-2010 03:23 PM

rsync issue
 
Rodolfo Medina <rodolfo.medina@gmail.com> writes:

> [...] the following is good for me:
>
> $ cd
> $ rsync -vrtul --delete --exclude='.*' . 192.168.0.2:/home/rodolfo


Sorry, it's still bad for me. I want to copy everything but top level hidden
files, i.e. hidden files from my home directory. The above command excludes
all hidden files from anywhere. How can I achieve what I want? I tried with:

--exclude='./.*'

but it doesn't work either, because it includes hidden files from `~/'.

Thanks for any help
Rodolfo


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
Archive: 87mxrdiwpi.fsf@gmail.com">http://lists.debian.org/87mxrdiwpi.fsf@gmail.com


All times are GMT. The time now is 08:52 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.