Browse Source

Merge pull request #4 from maxadamo/patch-1

using "su -" instead of su
Emmanuel B 2 years ago
parent
commit
4c557a863b
1 changed files with 3 additions and 3 deletions
  1. 3 3
      autopostgresqlbackup

+ 3 - 3
autopostgresqlbackup

@@ -356,9 +356,9 @@ dbdump () {
     for db in $1 ; do
         if [ -n "$SU_USERNAME" ]; then
             if [ "$db" = "$GLOBALS_OBJECTS" ]; then
-                su $SU_USERNAME -l -c "pg_dumpall $PGHOST --globals-only" >> $2
+                su - $SU_USERNAME -l -c "pg_dumpall $PGHOST --globals-only" >> $2
             else
-                su $SU_USERNAME -l -c "pg_dump $PGHOST $OPT $db" >> $2
+                su - $SU_USERNAME -l -c "pg_dump $PGHOST $OPT $db" >> $2
             fi
         else
             if [ "$db" = "$GLOBALS_OBJECTS" ]; then
@@ -453,7 +453,7 @@ fi
 # If backing up all DBs on the server
 if [ "$DBNAMES" = "all" ]; then
     if [ -n "$SU_USERNAME" ]; then
-        DBNAMES="$(su $SU_USERNAME -l -c "LANG=C psql -U $USERNAME $PGHOST -l -A -F: | sed -ne '/:/ { /Name:Owner/d; /template0/d; s/:.*$//; p }'")"
+        DBNAMES="$(su - $SU_USERNAME -l -c "LANG=C psql -U $USERNAME $PGHOST -l -A -F: | sed -ne '/:/ { /Name:Owner/d; /template0/d; s/:.*$//; p }'")"
     else
         DBNAMES="`LANG=C psql -U $USERNAME $PGHOST -l -A -F: | sed -ne "/:/ { /Name:Owner/d; /template0/d; s/:.*$//; p }"`"
     fi