borgbackup / borg

Deduplicating archiver with compression and authenticated encryption.
https://www.borgbackup.org/
Other
11.27k stars 747 forks source link

[Question/Feature request] Android backup via adb shell pipe #5184

Open Code7R opened 4 years ago

Code7R commented 4 years ago

Hello,

I checked the docs trying to find something to implement my idea but it is not helpful. The usecase: There is android device to backup with borg and it should work smooth in daily runs (thus: incremental) and fast on initial copy.

Constraints:

So I guess that to implement my idea, two steps are needed:

  1. port borg-serve to Android
  2. make it accessible through a pipe connection tool like rsh/ssh which can be used via $ BORG_RSH variable

Correct? If so: Regarding 1: has anyone tried this before? I cannot see any APK on the internet Regarding 2: is "adb shell" command sufficient for this purpose? Because otherwise, it would need some port of "rsh" tool, since ssh is too slow.

tsonntig commented 4 years ago

the adb backup command is deprecated.
You could backup your android device storage with mtp : `#!/bin/sh export BORG_REPO=/path/to/Backup export BORG_PASSPHRASE='password'

info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; } trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM info "Starting backup"

borg create \ --verbose \ --filter AME \ --list \ --progress \ --stats \ --show-rc \ --compression zstd,18 \ --exclude-caches \ --files-cache mtime,size \ \ ::'{hostname}-{now}' \ /run/user/$UID/gvfs/mtp* \

backup_exit=$?

info "Pruning repository"

borg prune \ --list \ --prefix '{hostname}-' \ --show-rc \ --stats \ --keep-daily 2 \ --keep-weekly 4 \ --keep-monthly 8 \ --keep-yearly 16 \

prune_exit=$?

global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit ))

if [ ${global_exit} -eq 0 ]; then info "Backup and Prune finished successfully" elif [ ${global_exit} -eq 1 ]; then info "Backup and/or Prune finished with warnings" else info "Backup and/or Prune finished with errors" fi

exit ${global_exit}

`

Code7R commented 4 years ago

If that works for you, fine. I have a general problem with mtpfs, only a little fraction of my phones has ever worked with it properly. Although I am not using Gnome, maybe it's better there.