Skip to content

Instantly share code, notes, and snippets.

@Tatsh
Last active April 8, 2020 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tatsh/8367388 to your computer and use it in GitHub Desktop.
Save Tatsh/8367388 to your computer and use it in GitHub Desktop.
Backup deb files of stuff you installed on your iOS device to your system. Just pass the IP address or host name and the place where to store them (that directory will not be created for you). This works best if you use key authentication with SSH (as you always should). Before using this you also need to install sudo, visudo to make sure you ca…
#!/usr/bin/env bash
rsync='rsync --progress --force --delete-before -rltvd'
target="${1:-tatshphone}"
target_local="${2}"
if [ -z "$target_local" ]; then
target_local="/mnt/spare/backup/${target}"
fi
for i in update upgrade autoremove clean; do
ssh "$target" "sudo apt-get -q -y $i" || exit 1
done
ssh "$target" 'sudo dpkg --get-selections | \
grep -v -E "gsc|cy\+|base|bash|dpkg|cydia|firmware|evasi0n|corona|racoon" | \
awk "{ print \$1 }" | \
sudo xargs apt-get install --force-yes -y --force-reinstall true -d' || exit 1
$rsync --exclude=lock --exclude=partial "${target}:/var/cache/apt/archives/" "$target_local" || exit 1
# Clean up
ssh "$target" 'sudo apt-get -q -y clean' && \
ssh "$target" 'sudo rm -fv /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment