#!/bin/sh
#/ Usage: ghe-backup-pages-tarball
#/ Take a tarball snapshot of all Pages data.
#/
#/ Note: This script typically isn't called directly. It's invoked by the
#/ ghe-backup command when the tarball strategy is used.
set -e

# Bring in the backup configuration
cd $(dirname "$0")/../..
. share/github-backup-utils/ghe-backup-config

# Snapshot all Pages data or fake it when no /data/pages directory exists.
echo '
    if [ -d /data/pages ]; then
        ghe-export-pages
    else
        tar cvf - --files-from /dev/null
    fi
' | ghe-ssh "$GHE_HOSTNAME" /bin/sh > "$GHE_SNAPSHOT_DIR"/pages.tar
