Last active
November 12, 2020 07:29
This file contains hidden or 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 | |
echo -e "\nPreparing the temporary backup directory\n" | |
umask 0027 | |
export BACKUP_DIR=/var/tmp/backup-$(date +%Y-%m-%d) | |
mkdir $BACKUP_DIR | |
chgrp postgres $BACKUP_DIR | |
chmod 770 $BACKUP_DIR | |
echo -e "Done\n" | |
echo -e "\nBacking up the Red Hat Satellite 6 Databases" | |
runuser - postgres -c "pg_dump -Fc foreman > $BACKUP_DIR/foreman.dump" | |
runuser - postgres -c "pg_dump -Fc candlepin > $BACKUP_DIR/candlepin.dump" | |
mongodump --host localhost --out $BACKUP_DIR/mongo_dump >/dev/null 2>&1 | |
echo -e "\nDatabase Backup Complete" | |
echo -e "\nCompressing the Database Backup" | |
cd $BACKUP_DIR | |
tar -cvzf /root/backup.tar.gz * >/dev/null 2>&1 | |
cd ~ | |
echo "Done" | |
echo -e "\nDB is located at /root/backup.tar.gz. Please provide this file to Red Hat Technical Support" | |
echo -e "\nCleaning up the directories" | |
rm -rf $BACKUP_DIR | |
unset BACKUP_DIR | |
echo -e "\nDone" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment