{"id":395,"date":"2013-01-06T23:16:00","date_gmt":"2013-01-06T21:16:00","guid":{"rendered":"http:\/\/wp.oktay.com\/?p=395"},"modified":"2013-01-06T23:16:00","modified_gmt":"2013-01-06T21:16:00","slug":"backup-via-bash","status":"publish","type":"post","link":"https:\/\/wp.oktay.com\/?p=395","title":{"rendered":"backup via bash"},"content":{"rendered":"<p><code><br \/>\n#!\/bin\/bash<br \/>\nSERVER=\"192.168.0.142\"<br \/>\n#nice -n 20 dd if=\/dev\/mmcblk0p1 of=\/media\/iomega\/sheeva_sicherung\/mmcblockp1_`date +%d-%m-%Y`  bs=1M count=16K<br \/>\ncd \/<\/p>\n<p>echo -e \"checking if server is mounted... \\033[60G [ \\033[1;32m`date` \\033[0;37m ]\"<br \/>\nmount_chk=`cat \/proc\/mounts | grep cifs| grep $SERVER|cut -f3 -d\"\/\"`<\/p>\n<p>if [ $mount_chk!=$SERVER ]; then<br \/>\n        echo \"no mount, Please mount manually \"<br \/>\n        dte=\"Y\";<br \/>\n        read -p \"shall we mount it? Y\/N [Y]\" te;<br \/>\n        te=${te:-$dte};<br \/>\n        if [ $te = \"Y\" ]; then<br \/>\n                echo -e \"mount \/\/192.168.0.142\/videos \/media\/iomega\/ -o user=0,noatime \\033[60G [ \\033[1;32mdone \\033[0;37m ]\"<br \/>\n               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\" );<br \/>\nsleep 6<br \/>\n                mount \/\/192.168.0.142\/videos \/media\/iomega\/ -o user=0,noatime ||  (echo \"hat net geklappt, exiting...\";exit );<\/p>\n<p>        else<br \/>\n        echo \"exiting...\"<br \/>\n                exit<br \/>\n        fi<br \/>\nfi<\/p>\n<p>nice -n 20   echo -e \"starting backup... \\033[60G [ \\033[1;32m`date` \\033[0;37m ]\"<br \/>\nif [ -f \/tmp\/file_list ]; then<br \/>\n        echo \"datei \/tmp\/file_list existiert... l\u00f6schen oder benutzen ? ich l\u00f6sch ma\"<br \/>\n        dte=\"Y\";<br \/>\n        read -p \"shall I delete that file? Y\/N [Y]\" te;<br \/>\n        te=${te:-$dte};<br \/>\n        if [ $te = \"Y\" ]; then<br \/>\n                 rm \/tmp\/file_list<br \/>\n        else<br \/>\n                echo \"ok, using the existing file then...\"<br \/>\n        fi<br \/>\nfi<\/p>\n<p>find \/bin  \/boot  \/dev  \/etc  \/home  \/lib  \/lost+found  \/mnt  \/opt  \/root  \/sbin  \/usr  \/var > \/tmp\/file_list<\/p>\n<p>echo -e \"file list created, starting cpio...  \\033[60G [ \\033[1;32m`date` \\033[0;37m ]\"<br \/>\nnice -n 20   cat \/tmp\/file_list | cpio -o -H newc  > \/media\/iomega\/sheeva_sicherung\/mmcblockp1_`date +%d-%m-%Y`.cpio.img<br \/>\n#nice -n 20   cat \/tmp\/file_list | cpio -o -H newc  > \/media\/iomega\/sheeva_sicherung\/mmcblockp1_`date +%d-%m-%Y`.cpio.gz<br \/>\n#nice -n 20 dd if=\/dev\/mmcblk0p1 of=\/media\/iomega\/sheeva_sicherung\/mmcblockp1_`date +%d-%m-%Y`  bs=1M count=16K<\/p>\n<p>echo -e \"finish backup... \\033[60G [ \\033[1;32m`date` \\033[0;37m ]\"<\/p>\n<p><\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>#!\/bin\/bash SERVER=&#8221;192.168.0.142&#8243; #nice -n 20 dd if=\/dev\/mmcblk0p1 of=\/media\/iomega\/sheeva_sicherung\/mmcblockp1_`date +%d-%m-%Y` bs=1M count=16K cd \/ echo -e &#8220;checking if server is mounted&#8230; \\033[60G [ \\033[1;32m`date` \\033[0;37m ]&#8221; mount_chk=`cat \/proc\/mounts | grep cifs| grep $SERVER|cut -f3 -d&#8221;\/&#8221;` if [ $mount_chk!=$SERVER ]; then echo &#8220;no mount, Please mount manually &#8221; dte=&#8221;Y&#8221;; read -p &#8220;shall we mount it? Y\/N [Y]&#8221;&hellip; <a class=\"more-link\" href=\"https:\/\/wp.oktay.com\/?p=395\">Continue reading <span class=\"screen-reader-text\">backup via bash<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-395","post","type-post","status-publish","format-standard","hentry","category-bash","entry"],"_links":{"self":[{"href":"https:\/\/wp.oktay.com\/index.php?rest_route=\/wp\/v2\/posts\/395","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wp.oktay.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wp.oktay.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wp.oktay.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wp.oktay.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=395"}],"version-history":[{"count":2,"href":"https:\/\/wp.oktay.com\/index.php?rest_route=\/wp\/v2\/posts\/395\/revisions"}],"predecessor-version":[{"id":397,"href":"https:\/\/wp.oktay.com\/index.php?rest_route=\/wp\/v2\/posts\/395\/revisions\/397"}],"wp:attachment":[{"href":"https:\/\/wp.oktay.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wp.oktay.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wp.oktay.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}