open-android-backup icon indicating copy to clipboard operation
open-android-backup copied to clipboard

Not working with macOS 11.4

Open kissge opened this issue 3 years ago • 6 comments

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.

kissge avatar Jul 06 '22 13:07 kissge

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.

mrrfv avatar Jul 15 '22 17:07 mrrfv

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!

panomitrius avatar Sep 04 '22 06:09 panomitrius

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.

mrrfv avatar Sep 04 '22 08:09 mrrfv

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.

thetuxinator avatar Sep 08 '22 10:09 thetuxinator

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

giri256 avatar Sep 30 '22 20:09 giri256

@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 avatar Oct 20 '22 16:10 mrrfv

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!

mrrfv avatar Jan 11 '23 19:01 mrrfv