Skip to content

Commit fd5d6ce

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 fd5d6ce

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

rpi-clone

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ PGM=`basename $0`
2222
setup_command="$PGM-setup"
2323

2424
rsync_options="--force -rltWDEHXAgoptx"
25+
rsync_options_fat="--force -rltWDEHXAptx"
2526

2627
if [ `id -u` != 0 ]
2728
then
@@ -285,14 +286,22 @@ mount_partition()
285286

286287
rsync_file_system()
287288
{
288-
src_dir="$1"
289-
dst_dir="$2"
289+
part_num="$1"
290+
src_dir="$2"
291+
dst_dir="$3"
290292

291-
qprintf " => rsync $1 $2 $3 ..."
293+
qprintf " => rsync $1 $2 $3 $4..."
294+
295+
effective_options=${rsync_options}
296+
fstype=${src_fs_type[part_num]}
297+
if [[ "$fstype" == *"fat"* ]]
298+
then
299+
effective_options=${rsync_options_fat}
300+
fi
292301

293302
if [ "$3" == "with-root-excludes" ]
294303
then
295-
rsync $rsync_options --delete \
304+
rsync $effective_options --delete \
296305
$exclude_useropt \
297306
$exclude_swapfile \
298307
--exclude '.gvfs' \
@@ -306,7 +315,7 @@ rsync_file_system()
306315
$src_dir \
307316
$dst_dir
308317
else
309-
rsync $rsync_options --delete \
318+
rsync $effective_options --delete \
310319
$exclude_useropt \
311320
--exclude '.gvfs' \
312321
--exclude 'lost\+found/*' \
@@ -1681,7 +1690,8 @@ do
16811690
mount_partition ${src_device[p]} $clone_src ""
16821691
mount_partition $dst_dev $clone "$clone_src"
16831692
unmount_list="$clone_src $clone"
1684-
rsync_file_system "${clone_src}/" "${clone}" ""
1693+
rsync_file_system "${p}" "${clone_src}/" "${clone}" ""
1694+
16851695
unmount_list "$unmount_list"
16861696
fi
16871697
done
@@ -1699,7 +1709,7 @@ fi
16991709
mount_partition $dst_root_dev $clone ""
17001710
unmount_list="$clone"
17011711

1702-
rsync_file_system "//" "$clone" "with-root-excludes"
1712+
rsync_file_system "$root_part_num" "//" "$clone" "with-root-excludes"
17031713

17041714
for ((p = 1; p <= n_src_parts; p++))
17051715
do
@@ -1725,7 +1735,7 @@ do
17251735
fi
17261736

17271737
mount_partition "$dst_dev" "$dst_dir" "$unmount_list"
1728-
rsync_file_system "${src_mounted_dir[p]}/" "${dst_dir}" ""
1738+
rsync_file_system "${p}" "${src_mounted_dir[p]}/" "${dst_dir}" ""
17291739
unmount_list="$dst_dir $unmount_list"
17301740
fi
17311741
done

0 commit comments

Comments
 (0)