Last active
April 10, 2024 12:12
-
-
Save sostenesapollo/58b14c3cfc823467e5bdce0a03415b63 to your computer and use it in GitHub Desktop.
Script to Drop local postgres database, create another, restore backup and clean redis data.sh
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
# Drop local db with force | |
docker exec -it $(docker ps | grep postgres | awk '{print $1}') psql -U postgres -d postgres -c "DROP DATABASE pedegas WITH (FORCE);" | |
# Create DB | |
docker exec -it $(docker ps | grep postgres | awk '{print $1}') psql -U postgres -d postgres -c "CREATE DATABASE pedegas;" | |
# Restore DB | |
bash -c 'gunzip -c ~/Documents/*.tar.gz | pg_restore --dbname="postgresql://postgres:postgres@localhost:5432/pedegas"' | |
# Clean Redis data | |
docker exec -it $(docker ps | grep redis | awk '{print $1}') redis-cli -a ads FLUSHALL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment