1
0
Fork 0
scripts-admin-quickndirty-p.../oldies/script_multi-pg-comparaison-instances.sh

23 lines
602 B
Bash
Executable file

#!/bin/sh
ESCLAVE="a.b.c.d"
for i in $@; do
# On récupère le numéro de port
POSTGRESQL_PORT="$( pg_lsclusters | sed 's/[[:space:]]\+/ /g' | cut -f 2,3 -d ' ' | grep -w "$i" | cut -f 2 -d ' ' )"
if [ -z "$POSTGRESQL_PORT" ]; then
echo "ERREUR: pas de port trouvé pour '$i'." >&2
continue
fi
# dump1 : local
DUMP1=$( mktemp local-XXXX )
DUMP2=$( mktemp distant-XXXXX )
su -l -c "pg_dumpall -p $POSTGRESQL_PORT" postgres > $DUMP1
su -l -c "ssh postgres@$ESCLAVE pg_dumpall -p $POSTGRESQL_PORT" postgres > $DUMP2
echo "$i..."
diff -u "$DUMP1" "$DUMP2"
rm -f "$DUMP1" "$DUMP2"
done