Last active
March 22, 2022 19:07
-
-
Save mccun934/b7de279550ca6f6ad55f to your computer and use it in GitHub Desktop.
quick DB restore
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
## You probably shouldn't run this! | |
foreman-maintain service stop | |
systemctl start mongod | |
systemctl start postgresql | |
su - postgres -c "dropdb candlepin && createdb candlepin" | |
su - postgres -c "dropdb foreman && createdb foreman" | |
mongo pulp_database --eval "db.dropDatabase()" | |
mongorestore --db pulp_database --host localhost /backup/mongo_dump/pulp_database/ | |
su - postgres -c "pg_restore --disable-triggers -v -d candlepin /backup/candlepin.dump" | |
su - postgres -c "pg_restore --disable-triggers -v -d foreman /backup/foreman.dump" | |
CP_PASS=`grep jpa.config.hibernate.connection.password /etc/candlepin/candlepin.conf | awk -F= '{print $2}'` | |
F_PASS=`grep password /etc/foreman/database.yml | awk -F: '{print $2}' | sed 's/"//g'` | |
echo "ALTER USER candlepin WITH PASSWORD '$CP_PASS';" | sudo -u postgres psql | |
echo "ALTER USER foreman WITH PASSWORD '$F_PASS';" | sudo -u postgres psql | |
foreman-maintain service start | |
# You most likely will need to do a run of the installer + certs reset: | |
https://gist.github.com/mccun934/5eff0831f80bda1790d146430a19a59d | |
# if you hit Sequel::Migrator::Error: More than 1 row in migrator table | |
https://gist.github.com/mccun934/b25876d81d8940be1f758370b84b4e30 | |
# if candlepin won't start due to mismatched versions, run: | |
CP_PASS=`grep jpa.config.hibernate.connection.password /etc/candlepin/candlepin.conf | awk -F= '{print $2}'` | |
/usr/share/candlepin/cpdb --update --dbhost=localhost --dbport=5432 --database=candlepin --user=candlepin --password=$CP_PASS |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment