Skip to content

Instantly share code, notes, and snippets.

@sostenesapollo
Last active April 10, 2024 12:12
Show Gist options
  • Save sostenesapollo/58b14c3cfc823467e5bdce0a03415b63 to your computer and use it in GitHub Desktop.
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
# 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