Skip to content

Commit

Permalink
v2022.5.12 202205120
Browse files Browse the repository at this point in the history
- C flag: exclude all *[cC]ache* files/directories globally (alternative to -X '*[cC]ache*');
- Do not backup/restore SSAIDs if /data/system/users/0/settings_ssaid.xml is encrypted;
- Updated info and support texts.
  • Loading branch information
VR-25 committed May 12, 2022
1 parent dbd1f79 commit e85288a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 16 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
v2022.5.12 202205120
- C flag: exclude all *[cC]ache* files/directories globally (alternative to -X '*[cC]ache*');
- Do not backup/restore SSAIDs if /data/system/users/0/settings_ssaid.xml is encrypted;
- Updated info and support texts.

v2022.may.9 202205090
- Initial release
2 changes: 1 addition & 1 deletion NOTICE
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This program, along with all included binaries (busybox, openssl, tar and zstd), are free and open source software.
They are provided as-is, and come with absolutely no warranties.
They are provided "as is", and come with absolutely no warranties.
One can do whatever they want with those programs, as long as they follow the terms of each license.

The binaries are provided by @osm0sis and @Zackptg5 -- credits to them, other contributors, and original authors.
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tarb, a backup solution for Android
# Tarb, A Backup Solution for Android, With Recovery Mode Support


---
Expand All @@ -13,7 +13,7 @@ All required binaries/executables are included: busybox for general tools, opens
## NOTICE

This program, along with all included binaries (busybox, openssl, tar and zstd), are free and open source software.
They are provided as-is, and come with absolutely no warranties.
They are provided "as is", and come with absolutely no warranties.
One can do whatever they want with those programs, as long as they follow the terms of each license.

The binaries are provided by @osm0sis and @Zackptg5 -- credits to them, other contributors, and original authors.
Expand Down Expand Up @@ -66,3 +66,4 @@ Examples:
- [Telegram Profile](https://t.me/vr25xda)

- [Upstream Repository](https://github.com/VR-25/tarb)
- [XDA Thread](https://forum.xda-developers.com/t/tarb-a-backup-solution-for-android-with-recovery-mode-support.4443801)
42 changes: 29 additions & 13 deletions tarb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,12 @@ bkp() {
| sed -E 's/ +//; s/:.*//' > $BKP_DIR/${line% *}/runtime_perms
}

[ ! -f $SSAID ] || {
# backup ssaid
if grep -q '^\<\?xml version=' $SSAID; then
grep \"${line% *}\" $SSAID > $BKP_DIR/${line% *}/ssaid \
&& echo " ssaid" \
|| rm $BKP_DIR/${line% *}/ssaid
} 2>/dev/null || :
fi 2>/dev/null || :

} || :

Expand Down Expand Up @@ -128,7 +129,7 @@ bkp_r() {
}

# restore ssaid
if [ -f $SSAID ] && [ -f $BKP_DIR/${line% *}/ssaid ]; then
if [ -f $BKP_DIR/${line% *}/ssaid ] && grep -q '^\<\?xml version=' $SSAID; then
echo " ssaid"
(set -- $(cat $BKP_DIR/${line% *}/ssaid)
name=$(stat -c %u /mnt/expand/*/user/0/${line% *} /data/data/${line% *} 2>/dev/null || :)
Expand Down Expand Up @@ -382,7 +383,7 @@ flag() {

help() {
cat << EOF | more
Tarb, a backup solution for Android
Tarb, A Backup Solution for Android, With Recovery Mode Support
Copyright (C) $1, $AUTHOR
License: GPLv3+
$2
Expand All @@ -398,7 +399,7 @@ All required binaries/executables are included: busybox for general tools, opens
NOTICE
This program, along with all included binaries (busybox, openssl, tar and zstd), are free and open source software.
They are provided as-is, and come with absolutely no warranties.
They are provided "as is", and come with absolutely no warranties.
One can do whatever they want with those programs, as long as they follow the terms of each license.
The binaries are provided by @osm0sis and @Zackptg5 -- credits to them, other contributors, and original authors.
Expand Down Expand Up @@ -464,6 +465,8 @@ Flags
c custom (paths)
C exclude all *[cC]ache* files/directories globally (alternative to -X '*[cC]ache*')
d data (user and user_de)
D exclude device encrypted data (data_de, from /data/user_de/)
Expand Down Expand Up @@ -555,6 +558,8 @@ Examples
Notes/tips
NO WARRANTIES, use at your own risk!
Tarb copies itself to the backup directory, as needed (filename: ".tarb" (hidden)).
Currently using $BKP_DIR/.
Expand All @@ -576,6 +581,13 @@ Notes/tips
Recovery mode support depends on whether the recovery can mount and decrypt the target storage devices (including adopted storage).
System settings and app runtime permissions cannot be backed up from recovery.
Regular (legacy) Android ID is backed up and restored as part of generic system settings (the s flag).
If $SSAID is encrypted, SSAIDs are not backed up / restored.
SSAIDs seem to be tied to Google Play Services -- meaning, alterntives such as MicroG don't have this "problem".
While Google email accounts can be backed up manually, restoring those is not guaranteed to work.
Android seems to be going the iOS way of things -- too many limitations.
Each app is paused before data backup, and stopped prior to restore.
For obvious reasons, this does not apply to terminal emulators.
Expand All @@ -595,9 +607,7 @@ Notes/tips
If a backup/restore fails, the old data is preserved.
When reporting issues, one should provide as many details as possible, along with a copy of $TMPDIR/log.
NO WARRANTIES, use at your own risk!
When reporting issues, one shall provide as much information as possible, along with a copy of $TMPDIR/log.
EOF
}

Expand Down Expand Up @@ -912,8 +922,8 @@ PASSF=$TMPDIR/.pass

AUTHOR="VR-25 @ GitHub"
COPYRIGHT_YEAR=2022
DESCRIPTION="Backup/restore apps and respective data, SSAIDs, runtime permissions, system settings, Magisk modules, and more."
VERSION="v2022.may.9 202205090"
DESCRIPTION="Backup/restore apps and respective data, SSAIDs, runtime permissions, generic system settings, Magisk modules, and more."
VERSION="v2022.5.12 202205120"

[ -z "${LINENO-}" ] || export PS4='$LINENO: '
mkdir -p ${BKP_DIR##* } $BIN_DIR
Expand Down Expand Up @@ -949,14 +959,20 @@ fi
exec 3<&0 4>&1
FLAGS=${1#-?}

# no cache?
! flag C && : > $X || {
echo "*[cC]ache*" > $X
FLAGS=$(echo "$FLAGS" | tr -d C)
}

# zstd compression level
COMP_LEVEL=1
! match $FLAGS "*[0-9]*" || {
! flag "[0-9]" || {
COMP_LEVEL=$(echo $FLAGS | grep -Eo '[0-9]+')
FLAGS=$(echo $FLAGS | sed -E 's/[0-9]+//')
}

! match "$FLAGS" "*[nx]*" || FLAGS=ad$FLAGS
! flag "[nx]" || FLAGS=ad$FLAGS
! match "${2-}" "*/*" || FLAGS=c$FLAGS
[ -n "$FLAGS" ] || FLAGS=ad

Expand Down Expand Up @@ -1028,7 +1044,7 @@ adb/magisk.db
com.google.android.gms.appid.xml
com.termux/files/home/shift
com.termux/files/home/storage
no_backup" > $X
no_backup" >> $X

# if flag "c*|*m"; then
# sed -Ei '/(art|dex|oat|lib)$/d' $X
Expand Down

0 comments on commit e85288a

Please sign in to comment.