Are you planning to run this directly from the raspberry PI itself? This could render inconsistencies in the filesystem copy. In order to do a full backup of the SD card you should insert the card in a computer and run a command similar to the one you've described.
About the two commands in your question:
Number 1 - Will work if sda1 is greater than mmcblk0. You would be wasting the remaining size of sda1 and will repeatedly be writing the same sectors of this destination device (not a good idea for flash memory).
Number 2 - You're are mixing device names (sda1) with filenames (backup.img). You are probably trying to do something like this:
sudo mkdir /tmp/backup_folder
sudo mount /dev/sda1 /tmp/backup_folder
sudo dd if=/dev/mmcblk0 of=/tmp/backup_folder/backup.img
What this commands do:
- Create folder for mounting sda1
- Mount sda1 in the folder created above
- Create image of SD in the root of sda1 filesystem
One last remark. You are saving the swap partition if you have any. This is useless. You are also copying empty filesystem space. Take a look at partimage available in all major distros. It will use less space and time.
/dev/sda1
is not a directory. – goldilocks Oct 04 '19 at 13:52