Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux backup support #10

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open

Conversation

tomchiverton
Copy link

This adds Linux specific scripts and menu for TA-Backup

At the moment, this is only for backup, and tested only on a Z1 Compact.

The created .zip has the same embedded version number for compatibility reasons, but has a TA.platform file containing the word 'Linux' to indicate it came from this branch.

@tomchiverton
Copy link
Author

Ref #6

@Hutchism
Copy link

Hutchism commented Nov 4, 2014

Hi Tom
Just got myself a Z2. Rooted today and happy to beta test your script for you :)

Good to have some Linux/mac support coming....

@tomchiverton
Copy link
Author

Please do test it. If it's possible to compare the files produced from Linux and Windows that would be handy e.g. unzip the file it produces and check (md5sum) that the files inside are the same.

@Hutchism
Copy link

Hutchism commented Nov 4, 2014

Can't test on Windows too easily right now. Tried the backup on Arch with this verbose:

  1. Backup
  2. Exit
    Please enter your choice: 1
    [sudo] password for ian:
  • daemon not running. starting it now on port 5037 *
  • daemon started successfully *
    3960 KB/s (1165484 bytes in 0.287s)

    FIND TA PARTITION

    partition Partition not found by name. No support yet for finding by other methods

    BACKUP TA PARTITION

    unknown operand not
    tmp-mksh: No: not found

INTEGRITY CHECK

FAILED - Backup does not match TA Partition. Please try again.
md5sum: md5sum: md5sum: md5sum: md5sum: tmp-mksh:
md5sum:

@tomchiverton
Copy link
Author

Please try my branch again and run the finding script directly

cd into the scripts/linux directory and run
export BB=/data/local/tmp/busybox-backup-ta
./find.sh

You should get output like :
Partition not found by name, trying harder

Please let me have that section, the lines starting ? or =

@tomchiverton
Copy link
Author

My branch should now locate the partition correctly on all supported devices.

Let me know.

@Hutchism
Copy link

Hutchism commented Nov 8, 2014

Hi Tom

Sorry for delay.

Output for your script:

  • daemon not running. starting it now on port 5037 *
  • daemon started successfully *
    6810 KB/s (1165484 bytes in 0.167s)
    Partition not found by name, trying harder
    Testing mmcblk0p1
    Testing mmcblk0p2
    Testing mmcblk0p3
    Testing mmcblk0p4
    Testing mmcblk0p5
    Testing mmcblk0p6
    Testing mmcblk0p7
    Testing mmcblk0p8
    Testing mmcblk0p9
    Testing mmcblk0p10
    Testing mmcblk0p11
    Testing mmcblk0p12
    Testing mmcblk0p13
    Testing mmcblk0p17
    Testing mmcblk0p19
    Testing mmcblk0p20
    Testing mmcblk0p21
    Testing mmcblk0p22
    Testing mmcblk0rpmb
    partition mmcblk0p1
    found by type /dev/block/mmcblk0p1
    found and valid /dev/block/mmcblk0p1

    FIND TA PARTITION

    partition
    No partition found

Output for
1|root@D6503:/ # cat /proc/partitions
cat /proc/partitions
major minor #blocks name

7        0       2111 loop0
7        1      23940 loop1
7        2       9387 loop2

179 0 15388672 mmcblk0
179 1 2048 mmcblk0p1
179 2 512 mmcblk0p2
179 3 256 mmcblk0p3
179 4 64 mmcblk0p4
179 5 512 mmcblk0p5
179 6 512 mmcblk0p6
179 7 512 mmcblk0p7
179 8 512 mmcblk0p8
179 9 256 mmcblk0p9
179 10 64 mmcblk0p10
179 11 512 mmcblk0p11
179 12 512 mmcblk0p12
179 13 512 mmcblk0p13
179 14 20480 mmcblk0p14
179 15 10240 mmcblk0p15
179 16 16384 mmcblk0p16
179 17 32 mmcblk0p17
179 18 16384 mmcblk0p18
179 19 1536 mmcblk0p19
179 20 1536 mmcblk0p20
179 21 1536 mmcblk0p21
179 22 8192 mmcblk0p22
179 23 2609152 mmcblk0p23
179 24 204800 mmcblk0p24
179 25 12359663 mmcblk0p25
179 32 4096 mmcblk0rpmb
179 64 15339520 mmcblk1
179 65 15338496 mmcblk1p1
254 0 2110 dm-0
254 1 23940 dm-1
254 2 9387 dm-2

Hope this helps

Ian

On 08/11/14 14:18, Tom Chiverton wrote:

My branch should now locate the partition correctly on all supported
devices.

Let me know.


Reply to this email directly or view it on GitHub
#10 (comment).

@tomchiverton
Copy link
Author

@Hutchism please try again. It runs through correctly on my Z1 compact now.

@Hutchism
Copy link

Hutchism commented Nov 9, 2014

Hi Tom

Seems to work now. Will try and compare it to a windows backup at some
point.

This is the output of your script:

FIND TA PARTITION

partition /dev/block/mmcblk0p1

BACKUP TA PARTITION

4096+0 records in
4096+0 records out
2097152 bytes transferred in 0.476 secs (4405781 bytes/sec)

INTEGRITY CHECK

PULL BACKUP FROM SDCARD

6050 KB/s (2097152 bytes in 0.338s)

INTEGRITY CHECK

PACKAGE BACKUP

adding: TA.img (deflated 88%)
adding: TA.md5 (stored 0%)
adding: TA.blk (stored 0%)
adding: TA.serial (stored 0%)
adding: TA.timestamp (stored 0%)
adding: TA.version (stored 0%)

adding: TA.platform (stored 0%)

This is the file list of tmpbak:
-rw-r--r-- 1 ian users 21 Nov 9 12:58 TA.blk
-rw-r--r-- 1 ian users 2.0M Nov 9 12:58 TA.img
-rw-r--r-- 1 ian users 33 Nov 9 12:58 TA.md5
-rw-r--r-- 1 ian users 14 Nov 9 12:58 TA.platform
-rw-r--r-- 1 ian users 11 Nov 9 12:58 TA.serial
-rw-r--r-- 1 ian users 18 Nov 9 12:58 TA.timestamp
-rw-r--r-- 1 ian users 5 Nov 9 12:58 TA.version


Suggest using tar instead of zip, as I had to download the zip command,
and the tar command is default on most distros including OSX.

Nice to see it progress! :)

Will let you know as soon as I've run it on Windows for compare.

Good on you! :) :) :)

Ian
On 09/11/14 12:51, Tom Chiverton wrote:

@Hutchism https://github.com/Hutchism please try again. It runs
through correctly on my Z1 compact now.


Reply to this email directly or view it on GitHub
#10 (comment).

@Hutchism
Copy link

Just so you know - md5s are same for both Windows and Linux :-)
On 4 Nov 2014 18:30, "tomchiverton" [email protected] wrote:

Please do test it. If it's possible to compare the files produced from
Linux and Windows that would be handy e.g. unzip the file it produces and
check (md5sum) that the files inside are the same.


Reply to this email directly or view it on GitHub
#10 (comment).

@GarciaLnk
Copy link

So far so good, tested in my Xperia Z1 Compact and it works very well, good job 👍

@mzazzali
Copy link

mzazzali commented Dec 7, 2014

I just tried this on my Xperia Z2 and it wasn't able to find the partition

$ ./Backup-TA.sh 
[ ------------------------------------------------------------ ]
[  Backup TA v9.11 for Sony Xperia                             ]
[ ------------------------------------------------------------ ]
[  Initialization                                              ]
[                                                              ]
[  Make sure that you have USB Debugging enabled, you do       ]
[  allow your computer ADB access by accepting its RSA key     ]
[  (only needed for Android 4.2.2 or higher) and grant this    ]
[  ADB process root permissions through superuser.             ]
[                                                              ]
[  On your computer, you need adb installed and working        ]
[ ------------------------------------------------------------ ]

1) Backup
2) Exit
Please enter your choice: 1
Password:
* daemon not running. starting it now on port 5037 *
* daemon started successfully *

It hangs here waiting after starting the daemon

I then ran the find script and this was the output

$ ./find.sh
error: device offline
error: device offline
error: device offline
expr: syntax error
Partition not found by name, trying harder
error: device offline
partition
No partitions found.

@tomchiverton
Copy link
Author

@mzazzali There is an issue with the adb install and/or your device. Was the device prompting you for anything ? Does "adb devices" say anything ? Does "adb shell" work ?

@mzazzali
Copy link

mzazzali commented Dec 8, 2014

So I ran

$ adb devices
List of devices attached 
CB5A21ZJQ5  offline

Then after reinstalling adb

$ adb devices
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
List of devices attached 
CB5A21ZJQ5  device

Then after rerunning the ./find.sh script

$ ./find.sh
expr: syntax error
Partition not found by name, trying harder
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
expr: syntax error
Testing
partition
No partitions found.

I am running this on OSX so that might be why I am getting a syntax error. I haven't looked at the script yet so I will probably do that next when I get some time.

@mzazzali
Copy link

mzazzali commented Dec 8, 2014

I found 2 issues one of them is OSX specific the other I am not sure what's causing it yet

The "expr: syntax error" issue is because the expr command doesn't exist on osx. So this script won't work without modifications on OSX which isn't the intent of this thread anyway. I'll see if I can fix those myself.

The second issues is that the check-root script is failing

$ ./check-root.sh 
Failed to obtain root : tmp-mksh: /data/local/tmp/busybox-backup-ta: not found

The script seems to think I don't have root. I was able to use a root checker app to verify I do have root after using towelroot. I also was able to install superSU.
In the check-root.sh file there is a variable BB that points to a directory that doesn't exist on my phone. This throws error throughout the script causing it to fail. I think its only for logging. I removed these and it seems to pass and correctly return /system/xbin/su as the path to su.

BB=/data/local/tmp/busybox-backup-ta

After a lot of hacking at the scripts it's still not finding the partitions

$ ./find.sh 
root=/system/xbin/su
PARTITION_BY_NAME=/dev/block/platform/msm_sdcc.1/by-name/TA

Partition not found by name, trying harder
mmcblk0p1
Testing mmcblk0p1
mmcblk0p2
Testing mmcblk0p2
mmcblk0p3
Testing mmcblk0p3
mmcblk0p4
Testing mmcblk0p4
mmcblk0p5
Testing mmcblk0p5
mmcblk0p6
Testing mmcblk0p6
mmcblk0p7
Testing mmcblk0p7
mmcblk0p8
Testing mmcblk0p8
mmcblk0p9
Testing mmcblk0p9
mmcblk0p10
Testing mmcblk0p10
mmcblk0p11
Testing mmcblk0p11
mmcblk0p12
Testing mmcblk0p12
mmcblk0p13
Testing mmcblk0p13
mmcblk0p17
Testing mmcblk0p17
mmcblk0p19
Testing mmcblk0p19
mmcblk0p20
Testing mmcblk0p20
mmcblk0p21
Testing mmcblk0p21
mmcblk0p22
Testing mmcblk0p22
mmcblk0rpmb
Testing mmcblk0rpmb
partition
No partitions found.

@tomchiverton
Copy link
Author

OSX is not Linux, and I have no way to test on that platform. I suggest you start a new thread and/or fork from this Linux branch?
Either way, wrong bug but good luck!

@famo
Copy link

famo commented Jun 2, 2015

I would like to try this on my Xperia z3 compact, too.

But, how do I get these files / scripts?

@lilydjwg
Copy link

I've tried this with my Xperia Z3C. It seems to work fine. Thank you.

@arnaudruffin
Copy link

This may not be the best place to write it, but just so you know i successfully backed up my Xperia Z3C on OSX, by slightly modifying the script.

I modified the expr command (only the first one because I didn't need to go further) like this:

backup_defaultTA=`expr "$backup_defaultTA" : '\([0-9a-z\/]*\)'`

Indeed, expr is shipped in osx but the "match" command is not supported

I also changed the local MD5 command

localmd5=`md5 $TMP/TA.img | awk {'print $4'} `

i created a fork with my modifications, if someone is interested:
https://github.com/arnaudruffin/Backup-TA

@squisher
Copy link

squisher commented Nov 9, 2015

Yet another fork based on arnaudruffin's with some minor bugfixes.

The script worked for me on Linux backing up a Z3 compact.

https://github.com/squisher/Backup-TA

@bam80
Copy link

bam80 commented Jan 21, 2017

@DevShaft will this be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants