Skip to content

Commit 1567f84

Browse files
Do not sync owner/group for FAT filesystems
This can potentially cause rsync error messages, especially if the filesystem is already mounted with a uid= option (which will not be copied to the destination mount, leading to different owners and thus rsync trying and failing to fix the owner).
1 parent 11a38f8 commit 1567f84

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

rpi-clone

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -285,14 +285,24 @@ mount_partition()
285285

286286
rsync_file_system()
287287
{
288-
src_dir="$1"
289-
dst_dir="$2"
288+
part_num="$1"
289+
src_dir="$2"
290+
dst_dir="$3"
290291

291-
qprintf " => rsync $1 $2 $3 ..."
292+
qprintf " => rsync $1 $2 $3 $4..."
293+
294+
effective_options=${rsync_options}
295+
fstype=${src_fs_type[part_num]}
296+
if [[ "$fstype" == *"fat"* ]]
297+
then
298+
# On FAT, owner and group are meaningless, so prevent
299+
# sync errors by not syncing those
300+
effective_options=${effective_options} --no-owner --no-group
301+
fi
292302

293303
if [ "$3" == "with-root-excludes" ]
294304
then
295-
rsync $rsync_options --delete \
305+
rsync $effective_options --delete \
296306
$exclude_useropt \
297307
$exclude_swapfile \
298308
--exclude '.gvfs' \
@@ -306,7 +316,7 @@ rsync_file_system()
306316
$src_dir \
307317
$dst_dir
308318
else
309-
rsync $rsync_options --delete \
319+
rsync $effective_options --delete \
310320
$exclude_useropt \
311321
--exclude '.gvfs' \
312322
--exclude 'lost\+found/*' \
@@ -1681,7 +1691,8 @@ do
16811691
mount_partition ${src_device[p]} $clone_src ""
16821692
mount_partition $dst_dev $clone "$clone_src"
16831693
unmount_list="$clone_src $clone"
1684-
rsync_file_system "${clone_src}/" "${clone}" ""
1694+
rsync_file_system "${p}" "${clone_src}/" "${clone}" ""
1695+
16851696
unmount_list "$unmount_list"
16861697
fi
16871698
done
@@ -1699,7 +1710,7 @@ fi
16991710
mount_partition $dst_root_dev $clone ""
17001711
unmount_list="$clone"
17011712

1702-
rsync_file_system "//" "$clone" "with-root-excludes"
1713+
rsync_file_system "$root_part_num" "//" "$clone" "with-root-excludes"
17031714

17041715
for ((p = 1; p <= n_src_parts; p++))
17051716
do
@@ -1725,7 +1736,7 @@ do
17251736
fi
17261737

17271738
mount_partition "$dst_dev" "$dst_dir" "$unmount_list"
1728-
rsync_file_system "${src_mounted_dir[p]}/" "${dst_dir}" ""
1739+
rsync_file_system "${p}" "${src_mounted_dir[p]}/" "${dst_dir}" ""
17291740
unmount_list="$dst_dir $unmount_list"
17301741
fi
17311742
done

0 commit comments

Comments
 (0)