The simplest way to back up your Raspberry Pi is to copy the entire SD card as an image.
This technique is the reverse of flashing your SD card when installing an OS to it. Instead of copying an image file from your computer to the SD card, you copy the entire SD card to an image file on your computer.
This is, in fact, how image files are created in the first place.
Power down your Raspberry Pi and remove the SD card. Place it into an SD card reader and connect it to your computer.
Open a Terminal window on a Mac or Linux computer, and enter df. Take a look at what drives you have on your system. Now attach the SD card to your computer, and enter df again.
Spot the newly mounted drive: on a Linux machine, it will be something like /dev/sdb1, and on a Mac it will say /dev/disk2s1. The numbers may be different, so be sure to check carefully.
sudo dd bs=4M if=/dev/sdb of=raspbian.img
On a Mac:
sudo dd bs=4m if=/dev/rdisk2 of=raspbian.img
You can then use the raspbian.img file to restore your entire operating system (in its current state) to an SD card using dd in reverse, or by using an app such as Etcher (etcher.io) to flash the SD card.
Backuo linux image (sd card)