-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Add ability to exclude arbitrary directories from backup #86
base: master
Are you sure you want to change the base?
Conversation
A few notes on this solution:
|
Looks good overall, thank you. I'll test this next weekend and then merge. |
You actually brought up a couple things I wanted to get your input on.
Correct. There is a way to do something equivalent with It currently exits with an error message on my test branch, but I don't think I've merged that change in yet.
That's something I was hoping to discuss. The plan is to change this to comma-delimited, with some other filtering to make any possible inputs shell-safe. Regardless of the delimiter though, I see 3 possible options for making the input more stable/robust:
or
or
Not sure what your thoughts are on that? Honestly I just wanted to get a proof of concept out, compare notes, and see if you had any feedback before I progress further. The whole project seems designed for simplicity and accessibility to non-technical users, and I'd like to not break that. |
I've done my own experiments with adding directory/file exclusions in the past (didn't merge it into the main branch because I couldn't figure out how to reliably exclude files with |
That would be helpful, if it's not too much work. Whenever I get some free time this week, I'll see if I can make a functional menu.
Bash scripting is nothing new to me, but there have been some very bizarre side effects/behaviors from the adb shell/mksh. It seems to be quite picky about the way scripts are fed to it. |
Here's a screenshot. My experimental code added a new
# ...
# Get device identifier from adb
device_id=$(adb devices | sed -n 2p | cut -f 1)
# Get the exclusions file location
exclusions_file="$HOME/.open_android_backup_exclusions_$device_id.txt"
# Define the items and their status
directories=$(adb shell find /storage/emulated/0 -type d | tr -d '\r')
options=()
for dir in $directories; do
# Dynamically set ON or OFF based on whether the directory already exists in the file
if [[ -f "$exclusions_file" && $(grep -c "^$dir$" "$exclusions_file") -eq 1 ]]; then
options+=("$dir" "" ON)
else
options+=("$dir" "" OFF)
fi
done
# Show the checklist and capture the output
selected=$(whiptail --title "Select directories to exclude" --checklist "Choose directories to exclude:" "$(expr $LINES - 8)" "$(expr $COLUMNS - 10)" "$(expr $LINES - 16)" "${options[@]}" 3>&1 1>&2 2>&3)
# ...
# Save exclusions to the home directory using the device id, each exclusion separated by a newline
echo "$selected" | tr ' ' '\n' | tr -d '"' > "$exclusions_file"
cecho "Exclusions saved to $exclusions_file - you can now run the script again and your exclusions will be loaded."
cecho "Warning! Exclusions are set on a per-device basis." Although it looks like my version doesn't seem to support directories with spaces either, as evidenced by the |
Thanks for this! I've had very little free time lately, but am 90% sure I can get a working implementation for adb. Will use this PR to document anything in the meantime. |
Fixes #85