Package: autopostgresqlbackup
Version: 1.0-5
Tags: patch
When using autopostgresqlbackup using the supplied config in
/etc/default/autopostgresqlbackup, it does backup as intended, but fails
to change back to the root directory afterwards:
"could not change directory to "/root": Permission denied" (reported as
error via email)
I think login-option of su should be used, so the commands are not run
in the /root directory (or from whereever autopostgresqlbackup was called).
I patched my autopostgresqlbackup as follows and it seems to work fine:
> --- usr/sbin/autopostgresqlbackup 2014-04-02 23:46:56.000000000 +0200
> +++ /usr/sbin/autopostgresqlbackup 2017-03-28 16:29:25.133861333 +0200
> @@ -357,9 +357,9 @@
> for db in $1 ; do
> if [ -n "$SU_USERNAME" ]; then
> if [ "$db" = "$GLOBALS_OBJECTS" ]; then
> - su $SU_USERNAME -c "pg_dumpall $PGHOST
> --globals-only" >> $2
> + su $SU_USERNAME -l -c "pg_dumpall $PGHOST
> --globals-only" >> $2
> else
> - su $SU_USERNAME -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
> @@ -449,7 +449,7 @@
> # If backing up all DBs on the server
> if [ "$DBNAMES" = "all" ]; then
> if [ -n "$SU_USERNAME" ]; then
> - DBNAMES="$(su $SU_USERNAME -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