Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

corrected backup script to detect loop and mmbclk device partitions #23

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/backup
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@

# unmount any partitions on the target device

a=9
while [ $a -gt 0 ]
do
sudo umount $1$a
a=`expr $a - 1`
done
sudo umount $1*

partprefix=$1
[[ $partprefix =~ ^/dev/(loop|mmcblk) ]] && partprefix=${partprefix}p
echo partprefix=$partprefix
# wipe the FAT on the target

sudo dd if=/dev/zero of=$1 bs=512 count=1
Expand Down Expand Up @@ -49,16 +47,16 @@ sudo parted /dev/mmcblk0 unit s print | tail -n +8 | head -n -1 | while read lin
# create file systems

if [ "$fstype" == "fat32" ] || [ "$fstype" == "fat16" ]; then
sudo mkfs.fat $1$pnum
sudo mkfs.fat $partprefix$pnum
fi
if [ "$fstype" == "ext4" ]; then
sudo mkfs.ext4 -F $1$pnum
sudo mkfs.ext4 -F $partprefix$pnum
fi

# mount and copy

sudo mount $1$pnum $dst
sudo mount /dev/mmcblk0p$pnum $src
sudo mount $partprefix$pnum $dst
sudo mount /dev/mmcblk0p$pnum $src
sudo cp -axv $src/. $dst/.
sudo umount $dst
sudo umount $src
Expand Down