Re: Rsync, how to include ~/.files but not ~/.dirs
On Thu, Jan 25, 2007 at 04:05:25AM +0000, ][ wrote:
> 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
--
Ken Irving, fnkci@uaf.edu
Reply to: