-
Notifications
You must be signed in to change notification settings - Fork 16
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
Added backup functions, device status (recovery,device,fastboot), fol… #28
Conversation
…der or partition size info
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! First things first, please use the fs module instead of calling stat. Then, run npm run lint-fix
to enforce the code style. Then we'll see about the rest :)
You still need to push your changes, afaics |
Yes know ! I would like to change some things regarding the backup function first ! |
I have issue with lint-fiw : `> eslint tests/unit-tests/.js src/.js "--fix" sh: 1: eslint: not found npm ERR! A complete log of this run can be found in: Do you have a hint for me ? |
Forget it, Some packages needs to be insalled, I fixed it |
…oTheThird, removed customcommandexec
@NeoTheThird Can you see the new commit ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some proposed tweaks and fixes.
Before merging, we also need to add some unit-tests, but let's think about this one first: Are you sure you want to go with the pipes approach? We had previously thought to tar on the device itself to get around buffer limitations and general adb flakyness. That way you could be a lot more certain that your backup would not be corrupted. What do you think?
Just my 2 cents, tar on the device puts quite a load on the flash. How is Android doing that? We do not want to wear out the sd card by doing too many backup cycles on it. |
In the end, we could also have a recovery with ssh or rsync, who says it must be adb only. |
Yes it can be also done via ssh,rsync but this mean that we need to enable the developers mode on the device right ? In fact I planned to write 2 backup function, and 2 restore functions, one "insitue" where the backup will take place on the device, the other one is the one I already wrote. |
Let it be in recovery for the time being. The folders are not accessible in an easy way during normal boot mode. |
That's not really that big of a problem. A tradeoff you might be willing to accept for the certainty that your backup does not fail silently.
No? The method described in ubports/ubports-installer#141 would work during normal boot as well. |
If we did it on normal boot, what will happens if we receive a SMS or a telegram during the backup task (even if we copy locally on the phone) ? I have nothing against the fact of doing it like you want, just one things is what will happens on the OS if it run out of space because of the tar operation ? |
It's not uncommon to back up linux desktops using tar, and they don't have a recovery. If you miss one sms, it usually doesn't hurt.
Yep, that's the limitation of that approach. If you don't have enough free space, you can't do it like that. |
And what about if we put the 2 possibilities and let the final user to choose. |
Could we discuss this further on Telegram or so, and stay here ontopic for the PR ;) - We got still the installer group there eg.g. |
What is the telegram group name please ? |
@Alain94W please send me your telegram name, I will invite you... |
This is : @Weiszaaaaa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly very nice, mainly just styling concerns. Only one slightly larger thing: Any chance you could add some tests for the new functions? Should be fairly straightforward if you base it on the existing tests.
var _this = this; | ||
return new Promise(function(resolve, reject) { | ||
_this | ||
.shell(["cat", "/etc/system-image/channel.ini", "|grep tag="]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What information do you want here, exactly? The tag is usually in the same line with the rest of the version-detail
.
Maybe we could rename this function to avoid confusion with getOs
. Maybe getUbuntuTouchVersionDetail
.
It would also be better to parse the response in javascript, rather than piping through grep.
}); | ||
} else if (stdout == "device") { | ||
// Device | ||
return this.shell("du -shk " + file + " |tail -n1") // + " --output=used|tail -n1")//df -hBK |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment still needed?
srcfile, | ||
" 2>/backup.pipe' | dd of=" + destfile | ||
]); | ||
//_this.execCommand(["exec-out 'tar -cvp ",srcfile," 2>/backup.pipe' | dd of="+destfile, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
still needed?
common.stdoutFilter("%]") | ||
]) | ||
.then((error, stdout, stderr) => { | ||
//process.platform == "win32" ? ' | findstr /v "%]"' : ' | grep -v "%]"'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
resolve(); // Everything's Fine ! | ||
}) | ||
.catch(e => { | ||
reject(e + ", Unable to delete the pipe "); | ||
}); // Pipe Deletion | ||
}) | ||
.catch(e => { | ||
reject(e + ", Unable to backuping the device "); | ||
}); // Backup start | ||
}) | ||
.catch(e => { | ||
reject(e + ", Pipe creation failed "); | ||
}); // Pipe Creation | ||
}) | ||
.catch(e => { | ||
reject(e + ", Unable to get the partition's filesize "); | ||
}); // Get file size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the comments here don't seem very useful
/* | ||
var lastSize = 0; | ||
_this.fileSize = bckSize; | ||
var progressInterval = setInterval(() => { | ||
_this | ||
.shell([ | ||
"stat", | ||
"-t", | ||
common.quotepath("/restore.pipe") | ||
]) | ||
.then(stat => { | ||
|
||
lastSize = eval(stat.split(" ")[1]); | ||
progress ((lastSize / _this.fileSize)*100); | ||
//lastSize = fileSizeInBytes/1024; | ||
}) | ||
.catch(e => { | ||
clearInterval(progressInterval); | ||
_this.log("failed to stat: " + e); | ||
}); | ||
}, 1000); | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
*/ | ||
|
||
// Start the restoration | ||
_this.log("Starting Restore..."); //adb push user.tar /resto.pipe & adb shell 'cd /; cat /resto.pipe | tar -xv' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment still needed?
]) | ||
.then((error, stdout, stderr) => { | ||
_this.log("Restore Ended"); | ||
//clearInterval(progressInterval); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
resolve(); // Everything's Fine ! | ||
}) | ||
.catch(e => { | ||
reject(e); | ||
}); // Pipe Deletion | ||
}) | ||
.catch(e => { | ||
reject(e); | ||
}); // Backup start | ||
}) | ||
.catch(e => { | ||
reject(e); | ||
}); // Pipe Creation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe include comments in error messages instead
Work continues in #39. Let's keep this one open until it's resolved for reference. |
Superseded by #39. Thanks again for your original work! |
Added backup function, devicestatus (recovery,device,bootloader) info, floder or partition size info, customecommand execution (not only adb for the backup). Started to write the restore function but not tested yet, working on the GUI first, do not use the restore function now.