tag:blogger.com,1999:blog-9007601562606157016.post337579826578213081..comments2023-05-11T16:21:37.725+01:00Comments on <Stuff about="code" />: Raspberry Pi - Auto BackupsMartin O'Hanlonhttp://www.blogger.com/profile/03047799173301971515noreply@blogger.comBlogger17125tag:blogger.com,1999:blog-9007601562606157016.post-88679859283747792092016-06-08T05:36:15.674+01:002016-06-08T05:36:15.674+01:00hi, does this method works while raspi is on runni...hi, does this method works while raspi is on running state ? or do i need to plugin my sdcard to another linux pc in order to backup ?Anonymoushttps://www.blogger.com/profile/17690980291386889805noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-75174675236425403322015-08-19T20:06:32.846+01:002015-08-19T20:06:32.846+01:00You could do that but if you setup the cron using ...You could do that but if you setup the cron using sudo i.e.:<br /><br />sudo crontab -e<br /><br />the command will run as a super user anyway.Martin O'Hanlonhttps://www.blogger.com/profile/03047799173301971515noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-65773775769207360022015-08-18T22:35:40.568+01:002015-08-18T22:35:40.568+01:00Martian,
Do you mean to add "sudo" be...Martian,<br /> Do you mean to add "sudo" before the script in the crontab? <br /><br />30 2 * * 1 /home/pi/runSDCardBackup.sh > /home/pi/SDCardBackup.log 2>&1<br /><br />or <br /><br />sudo 30 2 * * 1 /home/pi/runSDCardBackup.sh > /home/pi/SDCardBackup.log 2>&1Father's Rightshttps://www.blogger.com/profile/07223017348826749470noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-7778559062755963622015-08-16T06:40:24.095+01:002015-08-16T06:40:24.095+01:00Did you setup cron job using sudo? Did you give th...Did you setup cron job using sudo? Did you give the script execute permission?Martin O'Hanlonhttps://www.blogger.com/profile/03047799173301971515noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-88772489475902216142015-08-16T00:57:24.754+01:002015-08-16T00:57:24.754+01:00When the cron job kicks off I get an error (see be...When the cron job kicks off I get an error (see below) <br />/bin/sh: 1: /home/pi/myNAS/myShare/runSDCardBackup.sh: Permission denied<br />Any Thoughts?Father's Rightshttps://www.blogger.com/profile/07223017348826749470noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-32910279114556001752014-04-30T11:54:28.196+01:002014-04-30T11:54:28.196+01:00Thanks a lot for the tipThanks a lot for the tipMartin O'Hanlonhttps://www.blogger.com/profile/03047799173301971515noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-45842093151070728302014-04-30T00:03:30.013+01:002014-04-30T00:03:30.013+01:00Thank you for tutorial. I know this is quite old p...Thank you for tutorial. I know this is quite old post, but I would highly recommend to use bs=512k parameter to speed up cloning of SD card.Anonymoushttps://www.blogger.com/profile/17040151567958776285noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-10635663137568344252013-11-26T13:37:12.676+00:002013-11-26T13:37:12.676+00:00You'll dd the file back to the device. For ins...You'll dd the file back to the device. For instance:<br /><br /> # dd if=/path/to/NAS/drive/raspberryPiSDCardBackup.img of=/dev/mmcblk0<br /><br />The only tricky part is that you'll likely need to do it from another linux box since the pi would presumably be hosed at that point. Once that's done, stick the sd card back into the pi and reboot.<br />Jeffhttps://www.blogger.com/profile/08380466196663371527noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-77788003949920257142013-10-10T11:17:55.823+01:002013-10-10T11:17:55.823+01:00As a newbie to Linux this looks great but how do I...As a newbie to Linux this looks great but how do I restore the image to the SSD card. Probably a dumb question but thought I woud put it out there as it might help someone else also.<br />Cheers and thanks for sharingmalhttps://www.blogger.com/profile/08450694884250098331noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-788300378428858112013-04-16T13:31:20.985+01:002013-04-16T13:31:20.985+01:00If you setup cron using sudo (i.e. sudo crontab -e...If you setup cron using sudo (i.e. sudo crontab -e) all commands in that cron will run as root (and therefore not ask you for a root password)<br /><br />I suspect you are being asked for a password when you are using sudo because your user isn't in the /etc/sudoers file, see http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=17939. If you had your user to the sudoers file you wont be asked a password.<br /><br />MartMartin O'Hanlonhttps://www.blogger.com/profile/03047799173301971515noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-81276500706061536392013-04-15T21:06:06.409+01:002013-04-15T21:06:06.409+01:00Does the cron run sudo without asking for the pass...Does the cron run sudo without asking for the password? When I haven't used a sudo command in 5 minutes, it asks me to punch in the password again. How does your script handle this?Anthonyhttps://www.blogger.com/profile/16407103237141042287noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-23522193236553879562013-01-24T12:15:40.665+00:002013-01-24T12:15:40.665+00:00Hi, great how-to,
I was wondering if you could cre...Hi, great how-to,<br />I was wondering if you could create a script to automatically compress the image .img after finished backup and delete .img file or if there is a way to backup not all the SD Size (I have 32GB one) but only space occupied by OS because I have just 6GB occupied by Raspbian.<br /><br />Thanks<br />Steve<br />Anonymoushttps://www.blogger.com/profile/05191384321813748722noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-58731259498529732852013-01-06T23:47:20.665+00:002013-01-06T23:47:20.665+00:00Thanks for that information
I had seen a number o...Thanks for that information<br /><br />I had seen a number of posts about putting wait 'loops' into scripts to allow other commands to complete.<br />I had tested wait$! on some other commands (not dd) using date stamps output to a file, so I knew it worked.<br /><br />It is clear from date stamping before and after dd, that the script does come to a halt and wait for it to complete.<br /><br />I have re-written my script - which was based on the one you posted - to remove the unnecessary wait command.<br /><br />I added to the script so that weekly backup names alternate - one week its an 'A' backup and the next week its a 'B' backup.<br /><br />Regards<br /><br />anita2R anita2Rhttps://www.blogger.com/profile/10734009755213684657noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-89646465391422031322013-01-06T19:40:37.094+00:002013-01-06T19:40:37.094+00:00dd blocks the following command until it has finis...dd blocks the following command until it has finished there is no need to run it in the background and wait for it to finish.<br /><br />I explicitly use sudo within the script as I don't always wait for the schedule to run to backup the sd card and like you say cron runs as whatever user set it up, so being explicit allows the script to be re-used in other setups.Martin O'Hanlonhttps://www.blogger.com/profile/03047799173301971515noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-28195528842130228842013-01-06T18:16:34.696+00:002013-01-06T18:16:34.696+00:00Hi,
I think that your script will restart cron et...Hi,<br /><br />I think that your script will restart cron etc. as soon as the dd command has been issued.<br />The script does not wait for dd to complete before moving on to the next command.<br /><br />One way of making the script wait is to issue dd with a trailing '&' to make it a background process and then use wait $!<br />wait $! means wait for the last background process to complete.<br /><br />dd if=/dev/mmcblk0 of=/path/to/NAS/drive/raspberryPiSDCardBackup.img &<br />wait $!<br />/etc/init.d/cron start<br /><br />You shouldn't need sudo on every line as you have scheduled the script to run using 'sudo crontab -e'<br />This means the script will be run as root.<br /><br />If you scheduled the script to run by using 'crontab -e' it would be run as user and sudo would be required<br /><br />Regards<br />anita2Ranita2Rhttps://www.blogger.com/profile/10734009755213684657noreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-26652609165476010632012-12-28T15:08:45.030+00:002012-12-28T15:08:45.030+00:00Fantastic, works great!! Now I can tweak the setup...Fantastic, works great!! Now I can tweak the setup without worrying about losing all my settings.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-9007601562606157016.post-79611733766469632582012-09-06T03:54:51.399+01:002012-09-06T03:54:51.399+01:00Looks cool, thanks for the info. I'd like to ...Looks cool, thanks for the info. I'd like to do something similar but have the img file be bootable so I could just write it back to the SD card (or another SD card) and have it boot from there. I think that wouldn't work with your method above? Or would it?Doughttps://www.blogger.com/profile/09856253803743292805noreply@blogger.com