For anyone reciving this error on a device that is 4.0+: What fixed it for me was to add a -d to the command before 'backup' the -d command "Directs command to the only connected USB device" for example the command, with this fix, will now look like:
adb -d backup -apk -shared -all -f...