#!/usr/local/bin/bash
#/ 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
. $( dirname "${BASH_SOURCE[0]}" )/ghe-backup-config

bm_start "$(basename $0)"

# 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

bm_end "$(basename $0)"
