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 can run the required commands without a password.
#!/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/*'