Skip to content

Commit

Permalink
Merge pull request #105 from 3eggert/master
Browse files Browse the repository at this point in the history
make compression level adjustable
  • Loading branch information
mrrfv authored Feb 25, 2024
2 parents f2c7e83 + 8d2c5cb commit 3733f52
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ You need 3 functions in your hook for it to be properly initialized by the scrip

Please keep in mind that this project has minimal support for automation and very little support will be provided. In order to export contacts, you still need to have physical access to the device you're backing up as an "unattended mode" for the companion app hasn't been implemented yet.

There are 9 environment variables that control what the script does without user input:
There are 10 environment variables that control what the script does without user input:

1. `unattended_mode` - Instead of waiting for a key press, sleeps for 5 seconds. Can be any value.
2. `selected_action` - What the script should do when run. Possible values are `Backup` and `Restore` (case sensitive).
Expand All @@ -128,6 +128,7 @@ There are 9 environment variables that control what the script does without user
7. `use_hooks` - Whether to use hooks or not. Possible values are `yes` or `no` (case sensitive).
8. `data_erase_choice` - Whether to securely erase temporary files or not. Possible values are `Fast`, `Slow` and `Extra Slow` (case sensitive). The value of this variable is ignored if the command `srm` isn't present on your computer.
9. `discouraged_disable_archive` - Disables the creation of a backup archive, only creates a backup *directory* with no compression, encryption or other features. This is not recommended, although some may find it useful to deduplicate backups and save space. Restoring backups created with this option enabled is not supported by default; you must manually create an archive from the backup directory and then restore it. Possible values are `yes` or `no` (case sensitive).
10. `compression_level` - One of 0, 1, 3, 5, 7, 9. Where 9 is the best an slowest copression and 0 is no compression and the fastest level. If most of your data is already compressed, for example jpg pictures or mp3 videos, you will not loose much volume by compressing it.

Examples:

Expand Down
16 changes: 16 additions & 0 deletions backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,22 @@ fi

clear

if [ ! -v compression_level ]; then
cecho "Choose the compression level."
cecho "- 0 is no compression, and is the fastest."
cecho "- 3 is fast compression."
cecho "- 5 is normal compression, which is a balance between speed and file size."
cecho "- 7 is maximum compression, it was the previous default."
cecho "- 9 is the slowest, but provides the best compression."
cecho "Press Enter to pick your preferred compression level."
wait_for_enter

compression_levels=( '0' '1' '3' '5' '7' '9' )
select_option_from_list "Choose the compression level" compression_levels[@] compression_level
fi

clear

if [ ! -v use_hooks ]; then
cecho "Would you like to use hooks?"
cecho "Choose 'no' if you don't understand this question, or don't want to load hooks."
Expand Down
2 changes: 1 addition & 1 deletion functions/backup_func.sh
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function backup_func() {
# -bb3: verbose logging
# The undefined variable (archive_password) is set by the user if they're using unattended mode
declare backup_archive="$archive_path/open-android-backup-$(date +%m-%d-%Y-%H-%M-%S).7z"
retry 5 7z a -p"$archive_password" -mhe=on -mx=7 -bb3 "$backup_archive" backup-tmp/*
retry 5 7z a -p"$archive_password" -mhe=on -mx=$compression_level -bb3 "$backup_archive" backup-tmp/*
fi

# We're not using 7-Zip's -sdel option (delete files after compression) to honor the user's choice to securely delete temporary files after a backup
Expand Down

0 comments on commit 3733f52

Please sign in to comment.