mrrfv / open-android-backup

Back up your device without vendor lock-ins, using insecure software or root. Supports encryption and compression out of the box. Works cross-platform.
http://openandroidbackup.me/
GNU General Public License v3.0
674 stars 37 forks source link

Not working with macOS 11.4 #16

Closed kissge closed 1 year ago

kissge commented 1 year ago

Lots of errors are shown, and the script doesn't handle them and just keeps going.

$ git clone https://github.com/mrrfv/linux-android-backup
Cloning into 'linux-android-backup'...
remote: Enumerating objects: 283, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 283 (delta 4), reused 14 (delta 4), pack-reused 266
Receiving objects: 100% (283/283), 4.05 MiB | 8.35 MiB/s, done.
Resolving deltas: 100% (128/128), done.

$ ./backup.sh
Please enable developer options on your device, connect it to your computer and set it to file transfer mode. Then, press Enter to continue.
./backup.sh: line 20: [: -v: unary operator expected
If you have connected your device correctly, you should now see a message asking for access to your phone. Allow it, then press Enter to go to the last step.
Tip: If this is not the first time you're using this script, you might not need to allow anything.
./backup.sh: line 20: [: -v: unary operator expected
List of devices attached
xxxxxxxxxxxxxxx device

Can you see your device in the list above, and does it say 'device' next to it? If not, quit this script (ctrl+c) and try again.
./backup.sh: line 55: [: -v: unary operator expected
Linux Android Backup will install a companion app on your device, which will allow for contacts to be backed up and restored.
The companion app is open-source, and you can see what it's doing under the hood on GitHub.
Downloading companion app.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 16.2M  100 16.2M    0     0  3393k      0  0:00:04  0:00:04 --:--:-- 4470k
Attempting to uninstall companion app.
Installing companion app.
Performing Streamed Install
Success
Granting required permissions to companion app.
./backup.sh: line 92: [: =: unary operator expected
./backup.sh: line 147: [: =: unary operator expected
If this project helped you, please star the GitHub repository. It lets me know that there are people using this script and I should continue working on it.

I've not investigated very much, but macOS's bash is old and it has something to do with this issue.

$ bash --version
GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)
Copyright (C) 2007 Free Software Foundation, Inc.
mrrfv commented 1 year ago

I'm still on vacation, so my ability to help is very limited atm. Could you try changing #!/bin/bash to #!/bin/zsh in backup.sh and see if anything changes? IIRC zsh is the default shell in macOS, so it should be more up to date.

panomitrius commented 1 year ago

Getting similar errors.. Tried both with #!/bin/bash and #!/bin/zsh

When I run the script I get all this without typing anything:

bash ./backup.sh
./backup.sh: line 29: [: -v: unary operator expected
Please enable developer options on your device, connect it to your computer and set it to file transfer mode. Then, press Enter to continue.
./backup.sh: line 20: [: -v: unary operator expected
./backup.sh: line 29: [: -v: unary operator expected
If you have connected your device correctly, you should now see a message asking for access to your phone. Allow it, then press Enter to go to the last step.
./backup.sh: line 29: [: -v: unary operator expected
Tip: If this is not the first time you're using this script, you might not need to allow anything.
./backup.sh: line 20: [: -v: unary operator expected
List of devices attached
RF8MC0XCSQN device

./backup.sh: line 29: [: -v: unary operator expected
Can you see your device in the list above, and does it say 'device' next to it? If not, quit this script (ctrl+c) and try again.
./backup.sh: line 84: [: -v: unary operator expected
./backup.sh: line 109: [: -v: unary operator expected
./backup.sh: line 118: [: -v: unary operator expected
./backup.sh: line 29: [: -v: unary operator expected
Linux Android Backup will install a companion app on your device, which will allow for contacts to be backed up and restored.
./backup.sh: line 29: [: -v: unary operator expected
The companion app is open-source, and you can see what it's doing under the hood on GitHub.
./backup.sh: line 29: [: -v: unary operator expected
Companion app already downloaded.
./backup.sh: line 29: [: -v: unary operator expected
Attempting to uninstall companion app.
./backup.sh: line 29: [: -v: unary operator expected
Installing companion app.
Performing Streamed Install
Success
./backup.sh: line 29: [: -v: unary operator expected
Granting required permissions to companion app.
./backup.sh: line 29: [: -v: unary operator expected
Cleaning up after previous backup/restore...
backup-tmp
./backup.sh: line 155: [: =: unary operator expected
./backup.sh: line 217: [: =: unary operator expected
./backup.sh: line 29: [: -v: unary operator expected
If this project helped you, please star the GitHub repository. It lets me know that there are people using this script and I should continue working on it.

Using MacOS 10.15.7 and

GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin19) Copyright (C) 2007 Free Software Foundation, Inc.

zsh 5.7.1 (x86_64-apple-darwin19.0)

Regards!

mrrfv commented 1 year ago

Try running the script directly with zsh, i.e. zsh ./backup.sh - the first line in the log you posted shows that the script is being interpreted by bash.

thetuxinator commented 1 year ago

If you add #!/bin/zsh to the script and run it using bash ./backup.sh the script is again run by bash, adding the shebang only has an effect if you make the actual script (.sh file) executable and run ./backup.sh without any shell in prefix.

giri256 commented 1 year ago

Can confirm. NOT WORKING on big sur 11.7, same thing as above, companion app won't open in phone and script exits

mrrfv commented 1 year ago

@kissge @thetuxinator @giri256 Could you try following the guide below and running the script with bash again? I feel like this error is definitely caused by Apple shipping an outdated version of Bash with macOS.

https://www.shell-tips.com/mac/upgrade-bash/

mrrfv commented 1 year ago

Reproduced on macOS 13 - you simply need to update bash with Homebrew to fix: brew install bash. I just updated the installation/usage instructions to make the script compatible with Macs. Thanks for reporting!