#!/bin/sh

ISSUE_DATE=`date +%Y%m%d`
ARCHIVE_NAME=mzrootfs_${ISSUE_DATE}.tar.gz

BACKUP_ENTRY=/mnt/__mzrootfs_entry

mkdir -p "${BACKUP_ENTRY}"
mount --bind "/" "${BACKUP_ENTRY}"

tar -C "${BACKUP_ENTRY}" -cvzpf "${BACKUP_ENTRY}/${ARCHIVE_NAME}" "." \
--exclude=./${ARCHIVE_NAME} \
--exclude=.${BACKUP_ENTRY} \
--exclude=.bash_history \
--exclude=.ssh/* \
--exclude=.ccache/* \
--exclude=./lost+found \
--exclude=./mnt/* \
--exclude=./tmp/* \
--exclude=./proc/* \
--exclude=./sys/* \
--exclude=./etc/mtab \
--exclude=./etc/ssh/ssh_host_* \
--exclude=./usr/portage \
--exclude=./usr/src/linux* \
--exclude=./var/tmp/* \
--exclude=./var/log/*.gz \
--exclude=./var/log/mmessages \
--exclude=./var/log/emerge.log \
--exclude=./var/log/emerge-fetch.log \
--exclude=./var/log/dmesg \
--exclude=./var/log/faillog \
--exclude=./var/log/lastlog \
--exclude=./var/log/wtmp \
--exclude=./var/log/xferlog \
--exclude=./etc/udev/rules.d/* \
--exclude=./root/dead.letter \
--exclude=./.* \
--exclude=./boot/*.old \
--exclude=./media

umount "${BACKUP_ENTRY}"
rmdir "${BACKUP_ENTRY}"

# End of archive_for_distribution.sh
