59 lines
1.1 KiB
Bash
Executable File
59 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
#Backupscript für SDCards
|
|
#made bei STP - tux-mania Support
|
|
#Licence GPL
|
|
#Date: 14.02.2017
|
|
#Important: not tested!
|
|
set -e
|
|
DEV=$1
|
|
#count changed for EFS Partition
|
|
COUNT=2
|
|
|
|
if [[ $(which test > /dev/null) == true ]]; then
|
|
echo "Do yoe need test for this script!"
|
|
exit 1
|
|
fi
|
|
|
|
#root check commented. make problems
|
|
#if [[ $USERNAME != root ]]; then
|
|
# echo "You have no root access. Please logon as root and retry!"
|
|
# exit 1
|
|
#fi
|
|
|
|
if [[ $# -eq 0 ]]; then
|
|
echo "Please add the SDCard Device the command line to restore the SDCard!"
|
|
exit 1
|
|
fi
|
|
|
|
if [ ! -e $DEV ]; then
|
|
echo "Device does not exist!"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -d $PWD/backup ]; then
|
|
echo "Backup directory exist. Please move or delete!"
|
|
exit 1
|
|
fi
|
|
|
|
mkdir backup
|
|
mkdir mnt
|
|
sfdisk -d $DEV > $PWD/backup/partitiontables
|
|
|
|
#backup boot partitions / fitst 512Bytes
|
|
dd if=$DEV of=$PWD/backup/boot.part.img bs=512 count=1
|
|
|
|
while [[ $COUNT -lt 3 ]]; do
|
|
if [ ! -b $DEV$COUNT ]; then
|
|
DEV=$DEV"p"
|
|
fi
|
|
mount $DEV$COUNT $PWD/mnt
|
|
tar cvfz $PWD/backup/thinpi$COUNT.tar.gz --directory="$PWD/mnt/" .
|
|
umount $PWD/mnt
|
|
let COUNT=COUNT+1
|
|
done
|
|
|
|
rm -rf $PWD/mnt
|
|
|
|
exit 0
|
|
|