Backup.sh script failing


(Klewis) #1

I'm having problems with the backup.sh script. When I run it I get.


mysource_matrix]# ./scripts/backup.sh

./scripts/backup.sh: line 89: Notice:: command not found

DB_DATABASE=mysource_matrix

DB_DBSYNTAX=pgsql

DB_HOSTSPEC=

DB_PASSWORD=

DB_PORT=

DB_PROTOCOL=unix

DB_SOCKET=

DB_USERNAME=matrix

ERROR: DATABASE TYPE '' NOT KNOWN



The strange thing is I ran it earlier today and it ran fine. The only changes I've made since then is to up the memory_limits directives in the main.inc and php.ini files and install and configure the squiz_server. On my evaluation installation when I run the backup.sh script there is an additional variable DB_PHPTYPE=pgsql. Where is this variable parsed from? Anyone got any ideas what may be causing this?



I am running it as root from the [system_root] directory on RH4ES with php-cli.


(Avi Miller) #2

All of that stuff is parsed from main.inc – You should be changing memory limits in index.php, not main.inc.


(Klewis) #3

[quote]All of that stuff is parsed from main.inc – You should be changing memory limits in index.php, not main.inc.
[right][post=“11226”]<{POST_SNAPBACK}>[/post][/right][/quote]



Yes, you’re correct. My typo. index.php is where I changed the memory settings. I diffed the main.inc files from the working and non-working installations looking for a inadvertant change they are the same except for the ROOT_URLS. So what is being parsed to populate the DB_PHPTYPE variable? If edit the script to locally define the variable it works. So what gives?


(Avi Miller) #4

DB_PHPTYPE comes from the DSN string (its parsed out of the first protocol definition of the DSN itself). I think you should log a bug in the bug tracker and upload the various configuration files so that the developers can take a look at it.


Also, please provide information about your environment (OS, PHP versions, etc).


(Nic Hubbard) #5

I am having problems running the script also, but mine says that pg_dump cannot be found. Here is what I get:


[root@localhost mysource_matrix]# ./scripts/backup.sh /home/websites/backups/mynewbackup.tar

DB_DATABASE=mysource_matrix

DB_DBSYNTAX=pgsql

DB_HOSTSPEC=

DB_PASSWORD=

DB_PHPTYPE=pgsql

DB_PORT=

DB_PROTOCOL=unix

DB_SOCKET=

DB_USERNAME=matrix

./scripts/backup.sh: line 113: pg_dump: command not found

Unable to create dumpfile ./matrix-2006-08-08_13-58.dump.

Aborting.


(Avi Miller) #6

pg_dump is a PostgreSQL utility. It means that the PostgreSQL bin directory is not in the path. You should edit the backup.sh script and provide the full path to pg_dump.


(Nic Hubbard) #7

Yeah, I don't want to screw something up.


Here it somewhere in these lines?


    case "${DB_PHPTYPE}" in
            "pgsql")
                    args="";
                    if [ "${DB_USERNAME}" != "" ]; then
                            args="${args} -U ${DB_USERNAME}";
                    fi
                    if [ "${DB_PASSWORD}" != "" ]; then
                            echo "I can't pass the password automatically because the psql command only supports prompting.";
                            args="${args} -W";
                    fi
                    if [ "${DB_HOSTSPEC}" != "" ]; then
                            args="${args} -h ${DB_HOSTSPEC}";
                    fi
                    if [ "${DB_PORT}" != "" ]; then
                            args="${args} -p ${DB_PORT}";
                    fi
                    if [[ -z $remote ]];then
                            pg_dump ${args} "${DB_DATABASE}"  > ${dumpfile}
                    else
                            ssh ${remote} "pg_dump ${args} > ${remotefile}"
                            scp ${remote}:${remotefile} ${dumpfile}
                            [[ $? == 0 ]] && ssh ${remote} "rm -f ${remotefile}"
                    fi
                    if [ $? -gt 0 ]; then
                            echo "Unable to create dumpfile ${dumpfile}."
                            echo "Aborting."
                            exit 5
                    fi
           ;;

(Avi Miller) #8
    pg_dump ${args} "${DB_DATABASE}"  > ${dumpfile}

Add the full path to pg_dump on this line:

    /path/to/pg_dump ${args} "${DB_DATABASE}"  > ${dumpfile}

(Nic Hubbard) #9

Seems like it worked, but I am still getting this at the end of the backup:


tar: --exclude=mynewbackup.tar: Cannot stat: No such file or directory

tar: --exclude=./cache/: Cannot stat: No such file or directory

tar: --exclude=matrix-
-backup.tar*: Cannot stat: No such file or directory

tar: Error exit delayed from previous errors


(Avi Miller) #10

You must run the script from the MySource Matrix root directory, and don't specify a filename on the command line, just a destination directory. In fact, to make it simplest, don't specify anything at all (just run /scripts/backup.sh). The script will automatically create a .tar.gz file for you.