mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Faster sdcard backup&restore

Tue Dec 04, 2012 3:57 pm

I have to read carefully your post because I'm not really aware about "nfsshare" but I want to ask you about one thing: from my understanding you have a raspberry that is the one you are using and you want to backup, a server (another computer) that act as monitoring server and drive a transmitter that is able to unplug/plug the power of the target raspberry and a "backup raspberry".
Is it right?
I'll ready again your post as soon I will be at home after work.

Der_Gute
Posts: 36
Joined: Wed Aug 15, 2012 6:14 am

Re: Faster sdcard backup&restore

Tue Dec 04, 2012 4:03 pm

Youre absolutely right.
I have a monitoring raspberry with the transmitter and a usbstick mounted.
The usbstick contains the nfsshare rootfs of the raspberry i want to backup. I have chosen an usbstick, because then i am independend from the size of the sdcard from the monitor raspberry.
The other raspberry is my raspberry i want to backup.
The Backupprocess will be initiated with unplugging/plugging in the raspberry i want to backup with the transmitter.

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Faster sdcard backup&restore

Fri Dec 14, 2012 11:34 am

Nice solution but it needs a "monitoring system" and other machines, I'm looking for something that can be applied to a single raspberry.

Any others ideas?

Der_Gute
Posts: 36
Joined: Wed Aug 15, 2012 6:14 am

Re: Faster sdcard backup&restore

Fri Dec 14, 2012 1:42 pm

Hi,
you could modify this solution by replacing the nfs share with a usb stick.
The only disadvantage you have then is, that you have to control the power via gpio when the raspberry totally gives up. If your backup and restore system dont need a failsavemode (in cases of hanging up of raspberry or something else) you could boot from sdcard, force rebooting from usbstick (root filesystem on usbstick) and then flash the .img to the sd card :-) After flashing you could reboot back to root filesystem of sdcard

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Faster sdcard backup&restore

Fri Dec 14, 2012 1:51 pm

I only want to schedule a backup once a week, not a self restore procedure.

Der_Gute
Posts: 36
Joined: Wed Aug 15, 2012 6:14 am

Re: Faster sdcard backup&restore

Fri Dec 14, 2012 1:53 pm

Hehe then force a reboot to the usb root filesystem once a week, and run a crontab which backs up your sdcard and then boot back to sdcard :D

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Faster sdcard backup&restore

Fri Dec 14, 2012 2:11 pm

Have you got a link to use a pendrive as boot device?
How can I switch from a working sdcard rasp to a pendrive booted rasp ?

Der_Gute
Posts: 36
Joined: Wed Aug 15, 2012 6:14 am

Re: Faster sdcard backup&restore

Fri Dec 14, 2012 2:38 pm

You have to edit the cmdline.txt of your fat partition of sdcard to boot from pendrive.
This can be automatically done by your crontab(see my scripts because i use the same method to change the bootsource).
http://www.raspberrypi.org/phpBB3/viewt ... 66&t=12015
Here you can see how to modify the cmdline.txt. its really simple :)

Code: Select all

sudo rm /boot/cmdline.txt
sudo echo "dwc_otg.lpm_enable=0 console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1 ip=192.168.2.109:192.168.2.107:192.168.2.1:255.255.255.0:rpi:eth0:off root=/dev/nfs nfsroot=192.168.2.107:/mnt/usbstick/,vers=3 rw rootwait"> /boot/cmdline.txt
The first line removes the old cmdline.txt
The Second line generates an output to /boot/cmdline.txt
This line you have to modify on your needs. I think it is quite easy in your case. Take your cmdline.txt and modify

Code: Select all

root=/dev/mmckp0 (however :D)
to

Code: Select all

root=/dev/devicename of pendrive (i.e. sda1<--root filesystem)

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Faster sdcard backup&restore

Thu Feb 28, 2013 3:10 pm

Back again :D
I'm using an old 256MB usb stick as swap drive but it isn't used since now (512MB rasp); I'm thinking on this scenario:reduce the swap to 192MB and create a copy of the boot partition I have on the live sd.
Once a week a crontab script changes the live cmdline.txt switching the root "part" of the string from

Code: Select all

root=/dev/mmcblk0p2
to

Code: Select all

root=/dev/sdX?
where X? is the pendrive boot partition.
After the same crontab script runs

Code: Select all

sudo reboot
and now the stick system is loaded. After the boot success I can run a script that restore the right cmdline.txt file on the sd card, runs "dd" the clone "sdX" real card to somewhere, and after

Code: Select all

sudo reboot
Is it fine from you pov?

Der_Gute
Posts: 36
Joined: Wed Aug 15, 2012 6:14 am

Re: Faster sdcard backup&restore

Thu Feb 28, 2013 3:33 pm

Hi,
lets define pendrive boot partition
The only thing you can change with the cmdline.txt is the device you want to load the root filesystem from.
In my point of view a boot partition is called the partition where cmdline.txt is placed on. And this you cant change.
so i modify your thoughts:
use the stick to place an alternative root filesystem on a partition(not your swap):-) (all this folders you can see when you ssh to the raspberry). The Problem i see is the size of the partition where the root filesystem lays on. I see you are planning 60 mb for the root filesystem? i dont know if it is enough.
Then change the cmdline.txt on the bootpartition of the sdcard to load this root filesystem on usb pendrive as you mentioned in your reply. A crontab is useful as you said :) when booted from pendrive change back cmdline.txt to sdcard and vice versa.


Kind regards
Dennis

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Faster sdcard backup&restore

Thu Feb 28, 2013 3:58 pm

great explaination!
Sure, I done a mistake thinking on the boot partition: my "system" must have only one ~60MB fat partition with the cmdline.txt :D
Thanks.
As you explained the 256MB stick is useless for my purpose, so I can use the last 2GB of unused space on the usb hdd drive I have attached.
Can I find something to use less than 2GB?In fact I need only to run a crontab with "dd", I don't need e complete/working operating system.

Der_Gute
Posts: 36
Joined: Wed Aug 15, 2012 6:14 am

Re: Faster sdcard backup&restore

Fri Mar 01, 2013 8:16 am

Hi,
i think you have no alternative when you are thinking about shrinking the system to <2GB.

just buy a 2gb pendrive or create a partition on your hdd you want to run from :mrgreen:
btw: for optimal performance i recommend to format the partition with ext3/4 instead of ntfs/fat


Kind Regards
Dennis

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Faster sdcard backup&restore

Mon Mar 04, 2013 1:28 pm

I miss one step:
I wrote the scrip that changes the cmdline.txt, I added it in crontab.
Now when the system executes the crontab script the raspberry will reboot and I have the "operating system" running on the "backup" partition? Is it ok?
I always use the same /boot folder in the fat partition on the sdcard, but in cmdline.txt I set the usb hdd partition as root.
Before doing this I have to rsync the "sd data partition" with the "usb hdd data partition" otherwise, after the change_root.sh I'll have an empty os partition.

Let's try to explain better:
SD CARD = fat32 (56MB) + ext4 (3,9GB)
USD HDD =NTSF (494GB) + ext4 (2GB) + ext4 (4GB for backup)

When the script runs it edits the cmdline.txt in the fat32 partition, the system will run "on the ext4 2GB partition" and now I can run the "dd" comando to have an img file of the ext4 partion that is on the sd.
Is it ok?

Der_Gute
Posts: 36
Joined: Wed Aug 15, 2012 6:14 am

Re: Faster sdcard backup&restore

Mon Mar 04, 2013 1:32 pm

Hi,
thats exactly how we do it :).
You can use the same mechanism to restore backups too! I think you got it =).

Kind regards
Dennis

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Faster sdcard backup&restore

Mon Mar 04, 2013 2:16 pm

Thanks!!!!!! :D

subnet
Posts: 39
Joined: Wed Dec 26, 2012 10:30 pm

Re: Faster sdcard backup&restore

Wed Mar 06, 2013 9:37 am

Hello,
hoping is not OT, I use EaseUS ALL-IN-ONE Partition Manager Software to backup my RasPi's sdcard.

Is a free software (free for home users) for Windows

I just turn off the RasPi, insert the SD in my SD reader and start backup of the partition.
When I need to restore, I just use the the restore option of EaseUS.

My 2 cent, hoping is useful to someone :-)

Piero

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Faster sdcard backup&restore

Wed Mar 06, 2013 3:49 pm

Also win32Image works fine but the goal is to have an automatic backup system.
I can update/upgrade/install software on my raspberry during the day and it backup itself autonomously in the night so I can restore to the previous day last working image.
You suggest a process that need to be start to a human.
:D

subnet
Posts: 39
Joined: Wed Dec 26, 2012 10:30 pm

Re: Faster sdcard backup&restore

Wed Mar 06, 2013 3:53 pm

Yes, my suggestion is the one I have used until now... not automated, of course. Sorry :-)

ASAP I will try your software ;-)

cheers,
Piero

mcgyver83
Posts: 358
Joined: Fri Oct 05, 2012 11:49 am

Re: Faster sdcard backup&restore

Mon Mar 11, 2013 3:29 pm

I'm testing the whole system now.
Works fine!
Thanks a lot for the support.
I'm going to try also this solution http://www.raspberrypi.org/phpBB3/viewt ... 63&t=35668.
In my scenario backup occurs in the night so the raspberry is on "idle", no one is using it so the "clone script" solution should be enough robust for my purpose.
In the meanwhile I learnt some new things.

miche
Posts: 3
Joined: Wed Oct 03, 2012 5:30 pm

Re: Faster sdcard backup&restore

Thu Apr 04, 2013 4:19 pm

Hi everybody, thank you for the backup/restore script!

Unfortunately this is not working for me because partclone.extfs fails while cloning the system partition:

Code: Select all

sudo partclone.extfs --clone --source /dev/mmcblk0p2 --output ../images/fat_matrix_2/system3.img
Partclone v0.2.48 http://partclone.org
Starting to clone device (/dev/mmcblk0p2) to image (../images/fat_matrix_2/system3.img)
Reading Super Block
extfsclone.c: Couldn't find valid filesystem superblock.
Partclone fail, please check /var/log/partclone.log !
so the problem should be a bad superblock in the partition, but the sd is running without problems on the rpi. It has been flashed with the last Raspbian image.

did this happen to anybody? any hint? thank you very much

Return to “Advanced users”