Created
June 7, 2017 18:02
-
-
Save TJM/04914fc6ad1a3ffc27f0acf286284266 to your computer and use it in GitHub Desktop.
Puppet Enterprise Backup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -e | |
# Simple Backup for Puppet Enterprise assuming all defaults and monolithic | |
BACKUPROOT=/backup | |
KEEPDAYS=30 | |
BACKUPDIR="${BACKUPROOT}/$(date +%F-%T)" | |
# Backup Files | |
umask 077 | |
mkdir -p "${BACKUPDIR}" | |
cd / | |
tar zcf "${BACKUPDIR}/etc-puppetlabs.tgz" etc/puppetlabs | |
tar zcf "${BACKUPDIR}/opt-puppetlabs-certs.tgz" opt/puppetlabs/server/data/console-services/certs opt/puppetlabs/server/data/postgresql/*/data/certs | |
# Backup Database | |
sudo -Hu pe-postgres /opt/puppetlabs/server/apps/postgresql/bin/pg_dumpall -c | gzip > "${BACKUPDIR}/all_databases.sql.gz" | |
# Cleanup Old Backups | |
find $BACKUPROOT -mtime +${KEEPDAYS} -delete |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment