backup via bash


#!/bin/bash
SERVER="192.168.0.142"
#nice -n 20 dd if=/dev/mmcblk0p1 of=/media/iomega/sheeva_sicherung/mmcblockp1_`date +%d-%m-%Y` bs=1M count=16K
cd /

echo -e "checking if server is mounted... \033[60G [ \033[1;32m`date` \033[0;37m ]"
mount_chk=`cat /proc/mounts | grep cifs| grep $SERVER|cut -f3 -d"/"`

if [ $mount_chk!=$SERVER ]; then
echo "no mount, Please mount manually "
dte="Y";
read -p "shall we mount it? Y/N [Y]" te;
te=${te:-$dte};
if [ $te = "Y" ]; then
echo -e "mount //192.168.0.142/videos /media/iomega/ -o user=0,noatime \033[60G [ \033[1;32mdone \033[0;37m ]"
mount //192.168.0.142/videos /media/iomega/ -o user=0,noatime || (echo "trying to mount... wait 7 sec"; ssh root@192.168.0.142 "/etc/init.d/samba start" );
sleep 6
mount //192.168.0.142/videos /media/iomega/ -o user=0,noatime || (echo "hat net geklappt, exiting...";exit );

else
echo "exiting..."
exit
fi
fi

nice -n 20 echo -e "starting backup... \033[60G [ \033[1;32m`date` \033[0;37m ]"
if [ -f /tmp/file_list ]; then
echo "datei /tmp/file_list existiert... löschen oder benutzen ? ich lösch ma"
dte="Y";
read -p "shall I delete that file? Y/N [Y]" te;
te=${te:-$dte};
if [ $te = "Y" ]; then
rm /tmp/file_list
else
echo "ok, using the existing file then..."
fi
fi

find /bin /boot /dev /etc /home /lib /lost+found /mnt /opt /root /sbin /usr /var > /tmp/file_list

echo -e "file list created, starting cpio... \033[60G [ \033[1;32m`date` \033[0;37m ]"
nice -n 20 cat /tmp/file_list | cpio -o -H newc > /media/iomega/sheeva_sicherung/mmcblockp1_`date +%d-%m-%Y`.cpio.img
#nice -n 20 cat /tmp/file_list | cpio -o -H newc > /media/iomega/sheeva_sicherung/mmcblockp1_`date +%d-%m-%Y`.cpio.gz
#nice -n 20 dd if=/dev/mmcblk0p1 of=/media/iomega/sheeva_sicherung/mmcblockp1_`date +%d-%m-%Y` bs=1M count=16K

echo -e "finish backup... \033[60G [ \033[1;32m`date` \033[0;37m ]"


Comments are closed.