Bug 157835

Summary: Do not copy symlinks or through mtree, or via rsync
Product: Base System Reporter: vladislav V. Prodan <universite>
Component: miscAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 8.2-STABLE   
Hardware: Any   
OS: Any   

Description vladislav V. Prodan 2011-06-13 14:00:23 UTC
You need to copy the skeleton directories without files contained therein, only subdirectories.
Problems arose with the symlinks.
Symlinks are ignored mtree and rsync.

# df -h /tmp
Filesystem    Size    Used   Avail Capacity  Mounted on
zroot/tmp     366G    168k    366G     0%    /tmp
# zfs get all zroot/tmp
NAME       PROPERTY              VALUE                 SOURCE
zroot/tmp  type                  filesystem            -
zroot/tmp  creation              &#1074;&#1090; &#1103;&#1085;&#1074;  1  3:15 2008  -
zroot/tmp  used                  284K                  -
zroot/tmp  available             366G                  -
zroot/tmp  referenced            168K                  -
zroot/tmp  compressratio         1.04x                 -
zroot/tmp  mounted               yes                   -
zroot/tmp  quota                 none                  default
zroot/tmp  reservation           none                  default
zroot/tmp  recordsize            128K                  default
zroot/tmp  mountpoint            /tmp                  local
zroot/tmp  sharenfs              off                   default
zroot/tmp  checksum              fletcher4             inherited from zroot
zroot/tmp  compression           on                    local
zroot/tmp  atime                 on                    default
zroot/tmp  devices               on                    default
zroot/tmp  exec                  on                    local
zroot/tmp  setuid                off                   local
zroot/tmp  readonly              off                   default
zroot/tmp  jailed                off                   default
zroot/tmp  snapdir               hidden                default
zroot/tmp  aclinherit            restricted            default
zroot/tmp  canmount              on                    default
zroot/tmp  xattr                 off                   temporary
zroot/tmp  copies                1                     default
zroot/tmp  version               4                     -
zroot/tmp  utf8only              off                   -
zroot/tmp  normalization         none                  -
zroot/tmp  casesensitivity       sensitive             -
zroot/tmp  vscan                 off                   default
zroot/tmp  nbmand                off                   default
zroot/tmp  sharesmb              off                   default
zroot/tmp  refquota              none                  default
zroot/tmp  refreservation        none                  default
zroot/tmp  primarycache          all                   default
zroot/tmp  secondarycache        all                   default
zroot/tmp  usedbysnapshots       115K                  -
zroot/tmp  usedbydataset         168K                  -
zroot/tmp  usedbychildren        0                     -
zroot/tmp  usedbyrefreservation  0                     -
zroot/tmp  logbias               latency               default
zroot/tmp  dedup                 off                   default
zroot/tmp  mlslabel                                    -
zroot/tmp  sync                  standard              default

How-To-Repeat: Creating a test directory with a symlink:
#!/bin/sh
symlink="ghgh gugh seee udjd"

mkdir -p /tmp/test/All /tmp/test-copy
cd /tmp/test/All

for i in $symlink; do
    mkdir ../$i
    ln -s ../$i $i
done

Script copying the skeleton directory using mtree:
#!/bin/sh
from_dir=/tmp/test
to_dir=/tmp/test-copy
mkdir -p $to_dir

cd $from_dir/;
mtree -c -d -i -n -k link,uname,gname,mode,flags > $to_dir/dir.txt

mtree -U -f $to_dir/dir.txt -p $to_dir

OR rsync:

#!/bin/sh
from_dir=/tmp/test
to_dir=/tmp/test-copy

rsync  -vraKz --include='*/' --exclude='*' $from_dir $to_dir
Comment 1 vsityz 2011-06-14 08:18:40 UTC
change line
mtree -c -d -i -n -k link,uname,gname,mode,flags > $to_dir/dir.txt

to line
mtree -c -r -i -n -k link,uname,gname,mode,flags > $to_dir/dir.txt
               ^^

it`s work

--
Best regards.
Comment 2 Jaakko Heinonen freebsd_committer freebsd_triage 2011-12-29 17:11:04 UTC
State Changed
From-To: open->closed

This is not really a bug report. Please ask questions on the 
freebsd-questions@ mailing list.