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
-- DB size in bytes | |
SELECT pg_size_pretty( pg_database_size('dbname') ); | |
-- Table size in bytes | |
SELECT pg_size_pretty( pg_total_relation_size('tablename') ); | |
-- All table sizes sorted by size desc | |
SELECT table_name, pg_size_pretty( pg_relation_size(quote_ident(table_name)) ) | |
FROM information_schema.tables |
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
#!/usr/bin/env bash | |
if [ "$1" == "-h" -o "$1" == "--help" ]; then | |
echo 'docker-compose-services: list all services found in the docker-compose.yml file' | |
exit | |
fi | |
cat docker-compose.y*ml | grep -oP '(?<=^ )(\w|-)+(?=:)' |
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
#!/usr/bin/env bash | |
# | |
# taillog: tail FILE highlighting with colors the severity. | |
# | |
# Based in the script found at https://serverfault.com/a/1022806/256983 | |
# | |
# TODO: check whether the syntax "\<MESSAGE\>" offers better compatibility than "\bMESSAGE\b" to match whole words only (Mac OS) | |
if [ "$1" = "-h" -o "$1" = "--help" ] | |
then |
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
# \t\a\o /tmp/out.json | |
--Tuples only is off. | |
--Output format is aligned. | |
SELECT row_to_json(r) FROM my_table AS r; | |
# \t\a\o | |
--Tuples only is off. | |
--Output format is aligned. |
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
#!/usr/bin/env sh | |
DB="pg-latest_data" | |
DB_BCK="pg-latest_data-backup-$(date --iso-8601)" | |
#DB_BCK="pg-latest_data-backup-SNAPSHOT" | |
echo "Restoring backup of '$DB' database with backup '$DB_BCK' ..." | |
echo | |
docker-compose down | |
docker volume rm $DB |
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
#!/usr/bin/env bash | |
if [ "$#" -ne 1 -o "$1" == "-h" -o "$1" == "--help" ]; then | |
echo 'docker-sh: start a shell session with the container passed' | |
echo | |
echo "Use: docker-sh CONTAINER_NAME" | |
echo | |
echo "NOTE: partial names can be used, but the session" | |
echo " is started only if one container match" | |
exit 2 |
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
#!/usr/bin/env bash | |
if [ "$#" -ne 1 -o "$1" == "-h" -o "$1" == "--help" ]; then | |
echo "docker-volume-sh: start a shell session with the volume mounted at /data" | |
echo | |
echo "Use: docker-volume-sh VOLUME" | |
echo | |
echo "NOTE: if VOLUME does not exist, docker creates it first" | |
echo | |
exit 2 |
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
#!/usr/bin/env sh | |
if [ "$#" -ne 2 ]; then | |
echo "docker-volume-cp: copy one Docker volume content to another" | |
echo | |
echo "Use: docker-volume-cp VOL_SOURCE VOL_DEST" | |
echo | |
echo "NOTE: if VOL_DEST does not exist, docker-volume-cp creates it first" | |
exit 2 | |
fi |
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
couchdb-latest: | |
image: couchdb | |
environment: | |
- COUCHDB_USER=admin | |
- COUCHDB_PASSWORD=couch | |
ports: | |
- "5984:5984" | |
volumes: | |
- couchdb-data-latest:/opt/couchdb/data | |
- couchdb-conf-latest:/opt/couchdb/etc/local.d |
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
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then | |
c_reset='\e[0m' | |
c_git_clean='\e[0;32m' | |
c_git_dirty='\e[0;31m' | |
else | |
c_reset= | |
c_git_clean= | |
c_git_dirty= | |
fi |