So backing up a an SD Card from your Raspberry Pi is not necessarily that straightforward ; normal procedure will be to poweroff , remove SD Card and Backup manually on a Mac/ PC.
It is however possible to backup a ‘Live Pi’ via command line/terminal to a USB flash/memory stick WITHOUT any disruption or shutdown of your Pi.
The first thing you will need is a (fresh/clean) USB stick and I’ll take you through the formatting of that first. Insert the ‘Memory Stick’ to a spare USB port on your Pi and run the following command in terminal ;
Your device will most likely be listed as /dev/sda1 see pic below
As you can see this USB device (32Gb Sandisk Ultrafit) has already been in use and is formatted – BUT I wanted a clean disk so let’s do some formatting. Unmount the drive first with this command;
sudo umount /dev/sda1
Next we’re going to erase / format it as a NFTS drive but I will then also need to install support for this format first ;
sudo apt-get install ntfs-3g
I will create a directory (folder) for the USB drive (optional) like this;
sudo mkdir /mnt/usbstorage
create ownership with these commands;
sudo chown -R pi:pi /mnt/usbstorage sudo chmod -R 775 /mnt/usbstorage
We can now format and erase USB drive with this command (NTFS);
sudo mkfs.ntfs /dev/sda1 -f -v -I -L USBbackup
We can now start the backup of the SD card whilst our Pi is up and running, let’s identify devices type of the SD card;
sudo cat /etc/fstab
You should be able to identify a partition named /dev/mmcblk0p2 or very similar – lets execute the backup command;
sudo dd if=/dev/mmcblk0p2 of=/home/pi/untitled/AIY.img bs=8M
The cursor will be blinking intermittently for up to 20 mins during the backup process – do NOT interrupt this by shutting terminal down , good time to make a cup of tea. After about 20mins you will get a confirmation of successful backup.