Newsgroups: gmane.linux.debian.user Date: Thu, 25 Jan 2007 04:05:25 +0000 (UTC)
> Is there any way to tell rsync to backup all the . files under my home but > no any . directories? E.g., .profile in, but .gconf/ & .gnome/ etc out?
Don't use the recursive option?
Roberto C. Sanchez
> Is there any way to tell rsync to backup all the . files under my home but > no any . directories? E.g., .profile in, but .gconf/ & .gnome/ etc out? > > FYI, I tried with the following exclude rules but it didn't work, . directories > are still included. > > rsync -vua --exclude-from=exclude.list > > File exclude.list: > + /home/tong/.* > /home/tong/.*/
I created a little test tree under /tmp/home/:
$ find /tmp/home/ /tmp/home/ /tmp/home/paul /tmp/home/paul/.foo /tmp/home/paul/.dir1 /tmp/home/paul/.dir1/bar /tmp/home/paul/dir2 /tmp/home/paul/dir2/.file /tmp/home/paul/dir2/.dir3 /tmp/home/paul/dir2/.dir3/last /tmp/home/mary /tmp/home/mary/.foo /tmp/home/mary/.dir1 /tmp/home/mary/.dir1/bar /tmp/home/mary/dir2 /tmp/home/mary/dir2/.file /tmp/home/mary/dir2/.dir3 /tmp/home/mary/dir2/.dir3/last
With .dir1 in each user directory representing (I think) what you want to exclude. The following exclude pattern seems to work:
$ rsync -azvn --exclude=home/*/.*/ /tmp/home /tmp/rsync2 building file list ... done created directory /tmp/rsync2 home/ home/mary/ home/mary/.foo home/mary/dir2/ home/mary/dir2/.file home/mary/dir2/.dir3/ home/mary/dir2/.dir3/last home/paul/ home/paul/.foo home/paul/dir2/ home/paul/dir2/.file home/paul/dir2/.dir3/ home/paul/dir2/.dir3/last
sent 370 bytes received 98 bytes 936.00 bytes/sec total size is 0 speedup is 0.00
For some reason, .dir1/ is not excluded if the option is given as —exclude=/tmp/home/*/.*/ or —exclude=tmp/home/*/.*/.
Ken Irving
> > > For some reason, .dir1/ is not excluded if the option is given as > > > --exclude=/tmp/home/*/.*/ or --exclude=tmp/home/*/.*/. > > > > Expansion of unquoted globs in keyword arguments > > seldom gives the intended result. e.g. > > > > rsync --exclude=/home/*/.*/ /home/ /tmp/ > > > > might expand to: > > > > rsync --exclude=/home/a/.x/ /home/a/.y/ /home/b/.x/ /home/b/.y/ /home/ /tmp/ > > > > which copies a lot more than presumably intended. > > > > Mike Bird > > Duh... Thanks, I needed that. The one that worked wouldn't match > anything, so the globbing characters would pass through as is, but > otherwise would expand as you say. I've already deleted the test > files, but I'm confident (well, sort of...) that those forms would work > if quoted.
Well, tried that but they still don't work. This is probably because rsync is not dealing with the full paths (from /), so the longer patterns just don't match.
Ken Irving
>>> Is there any way to tell rsync to backup all the . files under my home but >>> no any . directories? E.g., .profile in, but .gconf/ & .gnome/ etc out? >>> >> Don't use the recursive option? > > unfortunately that's not an option. I have to use it. The OP is for > illustration purpose only.
That's contradicting what you said before. You want to rsync .files, so just drop the recursive option.
If you want to transfer all non-dot directories, maybe the easiest solution is to do rsync twice: once recursively without .files and once non-recursively for .files.
Johannes Wiedersich
> I should have said I was trying to backup the /home directory, > although the exclude list hinted so. I was trying to cut the craps, > not bring along a life long story, but apparently I trimmed too > much. :-) > > Ok, fair enough. two pass is a solution. But I have to add every > single user in my /home directory, and if there is change in account, > i.e. more or less people, I'll be in trouble.
You could script that part. A trivial example:
cd /home for FILE in $(ls); do file $FILE; done
> Anyway, if that's the only solution. fine.
I understand your frustration. A solution which allows you to distinguish between dot directories and other directories would be neater.
Liam O'Toole