Madison Kelly
2005-Jul-29 00:21 UTC
creating directories not specified in '--files-from' file
Hi all, I use 'rsync' in my backup program and I've run into an annoying bug. If I specify a directory to be backed up all files in it are copied automatically. This is a problem because a user may have selected specifically to not backup a given file. Also if a subdirectory exists in a specified directory it is also copied though do data below it is. I call 'rsync' via: =- 'rsync' call -sudo -b /usr/bin/rsync -aq --modify-window=1 --no-whole-file --partial --files-from=/path/to/list.txt /boot /dest/path =- 'rsync' call - In the 'list.txt' file I have this: =- 'list.txt' file -/ /System.map-2.4.27-2-686 /vmlinuz-2.6.8-2-686 /System.map-2.6.8-2-686 /initrd.img-2.4.27-2-686 /vmlinuz-2.4.27-2-686 /initrd.img-2.6.8-2-686 /grub /grub/reiserfs_stage1_5 /grub/fat_stage1_5 /grub/stage2 /grub/menu.lst~ /grub/stage1 /grub/jfs_stage1_5 /grub/minix_stage1_5 /grub/menu.lst /grub/xfs_stage1_5 /grub/device.map /grub/e2fs_stage1_5 /lost+found /test2/foo/bar/baz /test2 /test2/foo/bar /test2/foo =- 'list.txt' file - For example, I am testing my program by copying my '/boot' partition (because it is small) with a couple of test directories. One of those is '/boot/test/...' which, as you can see above, is not specified. I have also not specified the two 'config...' files also. When 'rsync' runs though this is what is created on the destination partition: =- 'ls -lah' of destination directory -sudo ls -lah /dest/path total 12M drwxr-xr-x 6 root root 4.0K 2005-07-15 18:35 . drwxr-xr-x 3 madison madison 4.0K 2005-07-28 20:11 .. -rw-r--r-- 1 root root 44K 2005-05-16 04:02 config-2.4.27-2-686 -rw-r--r-- 1 root root 55K 2005-05-19 04:51 config-2.6.8-2-686 drwxr-xr-x 2 root root 4.0K 2005-07-04 21:23 grub -rw-r--r-- 1 root root 4.0M 2005-07-04 15:46 initrd.img-2.4.27-2-686 -rw-r--r-- 1 root root 4.5M 2005-07-04 21:23 initrd.img-2.6.8-2-686 drwxr-xr-x 2 root root 4.0K 2005-07-04 15:41 lost+found -rw-r--r-- 1 root root 519K 2005-05-16 04:42 System.map-2.4.27-2-686 -rw-r--r-- 1 root root 824K 2005-05-19 05:27 System.map-2.6.8-2-686 drwxr-xr-x 2 root root 4.0K 2005-07-24 11:03 test drwxr-xr-x 3 root root 4.0K 2005-07-15 18:35 test2 -rw-r--r-- 1 root root 856K 2005-05-16 04:41 vmlinuz-2.4.27-2-686 -rw-r--r-- 1 root root 1.2M 2005-05-19 05:27 vmlinuz-2.6.8-2-686 =- 'ls -lah' of destination directory - This destination directory (partition) was blank before running 'rsync' so any data there is solely because of 'rsync'. Is there a way to tell 'rsync' not to copy sub directories or files in a given directory listed in '--files-from=...' unless specifically asked to do so? Thanks in advance! Madison
Wayne Davison
2005-Jul-29 02:05 UTC
creating directories not specified in '--files-from' file
On Thu, Jul 28, 2005 at 08:19:26PM -0400, Madison Kelly wrote:> If I specify a directory to be backed up all files in it are copied > automatically.That only happens if the dir has a trailing slash (which is telling rsync "I want the contents of this directory"), rather than just the directory's name (which is telling rsync "I want to create that dir"). In fact, you could omit all directory items when using --files-from for a backup (unless you happen to want to backup an empty directory). So, in your list.txt file, you should not be specifying "/" unless you want all the contents of the base dir to be copied. Just remove that line and your copy should be fine. ..wayne..