Sunday 28 August 2016

Raspberry Pi Backup

Here are the commands I use to preform a full backup of my raspi's. This will store the microsd card to either a usb stick(must be bigger than the microsd) and a backup to a share on my windows desktop.

USB Backup

sudo mkfs.vfat /dev/sda1 -n usbdrive
sudo mount /dev/sda1 /mnt
sudo chmod 755 /mnt
sudo dd if=/dev/mmcblk0p2 of=backupimage.img

Note: sda1 is the usb device , mmcblk0p2 is the memory card. Adjust acordenly.

Backup to Windows Pc


sudo mount -t cifs -o username=PI,password=PASSWORD//WINDOWSPC/share /mnt/smbbackup -o rw

sudo dd if=/dev/mmcblk0p2 of=/mnt/smbbackup/backupimage.img

 Note: mmcblk0p2 is the memory share

Save shutdown of raspberry pi

It's tempting to just pull the power when we move the pi but that will 
stress the SD card and eventually corrupt it.
so instead run the command.

sudo shutdown -h now