--- /dev/null
+#!/bin/sh
+set -e
+
+# FIXME: Fix sbuild to pass the chroot base path to this script!
+dsc=$1
+chroots=$(find /var/lib/schroot/mount/*/build/ -maxdepth 2 -name $dsc | wc -l)
+if test "$chroots" -eq 0; then
+ echo "$0: Failed to find chroot in /var/lib/schroot/mount." >&2
+ exit 1
+elif test "$chroots" -gt 1; then
+ echo "$0: Found multiple chroots (but only one wanted):" >&2
+ find /var/lib/schroot/mount/*/build/ -maxdepth 2 -name $dsc >&2
+ exit 1
+fi
+# FIXME: possible race condition
+chroot=$(readlink -f "$(dirname $(find /var/lib/schroot/mount/*/build/ -maxdepth 2 -name $dsc))/../..")
+
+echo "sudo rsync -a --exclude=/dev/ --exclude=/proc/ --exclude=/sys/ $chroot/ /tmp/$(basename $chroot)"
+sudo rsync -a --exclude=/dev/ --exclude=proc/ --exclude=/sys/ $chroot/ /tmp/$(basename $chroot)