From 9d9bc47df0c1688c732094cb1860da83dbae95c5 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Wed, 31 Jul 2024 22:17:48 +0200 Subject: [PATCH] chore: postgresql services file and rds commands --- knowledge base/postgresql.md | 9 +++++++++ snippets/ansible/tasks.yml | 7 +++++++ snippets/aws/commands.fish | 11 +++++++++++ 3 files changed, 27 insertions(+) diff --git a/knowledge base/postgresql.md b/knowledge base/postgresql.md index 35165c5..ea2b8bf 100644 --- a/knowledge base/postgresql.md +++ b/knowledge base/postgresql.md @@ -38,6 +38,14 @@ postgres.lan:5643:postgres:postgres:BananaORama *:*:sales:elaine:modestPassword EOF chmod '600' ~/'.pgpass' + +# Set up the per-user services file. +cat < ~/'.pg_service.conf' +[prod] +host = prod.0123456789ab.eu-west-1.rds.amazonaws.com +port = 5433 +user = master +EOF ``` ```sh @@ -51,6 +59,7 @@ psql 'my-db' 'user' psql 'postgresql://host:5433/my-db?sslmode=require' psql -U 'username' -d 'my-db' -h 'hostname' -p 'port' -W psql --host 'host.fqnd' --port '5432' --username 'postgres' --database 'postgres' --password +psql "service=prod sslmode=require" # List available databases. psql … --list diff --git a/snippets/ansible/tasks.yml b/snippets/ansible/tasks.yml index 0b262ff..6de39b3 100644 --- a/snippets/ansible/tasks.yml +++ b/snippets/ansible/tasks.yml @@ -384,3 +384,10 @@ -r --no-role-passwords changed_when: false register: dump_execution + - name: Wait for pending changes to be applied + amazon.aws.rds_instance_info: + db_instance_identifier: "{{ db_instance_identifier }}" + register: instance_check + retries: 12 + delay: 15 + until: instance_check.instances[0].pending_modified_values.keys() | length > 0 diff --git a/snippets/aws/commands.fish b/snippets/aws/commands.fish index 3692a0e..21c189f 100644 --- a/snippets/aws/commands.fish +++ b/snippets/aws/commands.fish @@ -79,6 +79,17 @@ echo {1..5} | xargs -p -n '1' -I '{}' aws rds start-export-task … aws rds describe-export-tasks --query 'ExportTasks[].WarningMessage' --output 'json' +aws rds restore-db-instance-to-point-in-time \ + --source-db-instance-identifier 'awx' --target-db-instance-identifier 'awx-pitred' \ + --restore-time '2024-07-31T09:29:40+00:00' \ + --allocated-storage '20' + +aws rds restore-db-instance-from-db-snapshot \ + --db-instance-identifier 'awx-pitr-snapshot' \ + --db-snapshot-identifier 'rds:awx-2024-07-30-14-15' + +aws rds delete-db-instance --skip-final-snapshot --db-instance-identifier 'awx' + aws s3api list-buckets --output 'text' --query 'Buckets[].Name' | xargs -pn '1' aws s3api list-multipart-uploads --bucket aws ec2 describe-volumes --output 'text' --filters 'Name=status,Values=available' \