...and pass the new db arguments to the commands to actually dump things
[hcoop/scripts.git] / hcoop-all-db-backup
index 33e79ab..e4367e5 100755 (executable)
@@ -13,9 +13,9 @@ if ! test -d "$BACKUP_ROOT"; then
        exit 1
 fi
 
-MYSQL_DBS=`sudo -H mysqlshow | tail -n +4 | head -n -1 | cut -d' ' -f 2 | xargs`
+MYSQL_DBS=`sudo -H mysqlshow --defaults-file=/root/.my.fritz.cnf | tail -n +4 | head -n -1 | cut -d' ' -f 2 | xargs`
 echo "Mysql Databases are: $MYSQL_DBS"
-PGSQL_DBS=`sudo -u postgres psql template1 -c '\l' | tail -n +4 | head -n -2 | cut -d' ' -f 2 | xargs`
+PGSQL_DBS=`sudo -u postgres psql -h postgres template1 -c '\l' | tail -n +4 | head -n -2 | cut -d' ' -f 2 | xargs`
 echo "Postgres Databases are: $PGSQL_DBS"
 
 # Delete oldest
@@ -41,11 +41,11 @@ mkdir --mode=770 "$BACKUP_ROOT/mysql" "$BACKUP_ROOT/postgres"
 
 # Perform MYSQL backup
 for db in $MYSQL_DBS; do 
-       sudo -H mysqldump "$db" | gzip - > "$BACKUP_ROOT/mysql/$db.gz"
+       sudo -H mysqldump --defaults-file=/root/.my.fritz.cnf "$db" | gzip - > "$BACKUP_ROOT/mysql/$db.gz"
 done
 
 # Perform PGSQL backup
 for db in $PGSQL_DBS; do 
-       sudo -H -u postgres pg_dump "$db" | gzip - > "$BACKUP_ROOT/postgres/$db.gz"
+       sudo -H -u postgres pg_dump -h postgres "$db" | gzip - > "$BACKUP_ROOT/postgres/$db.gz"
 done