Reputation: 11454
In order to create backups of a postgres DB, I downloaded the backup scripts provided here.
I created a pg_backup.config
which is located in /etc
. Put pg_backup.sh
in /usr/local/bin
. When trying to run the script, like so:
$ pg_backup.sh -c /etc/pg_backup.config
... I get the following error message:
/usr/local/bin/pg_backup.sh: line 27: /usr/local/bin/pg_backup.config: No such file or directory
Is there something I'm doing wrong? Obviously, the script tries to load the configuration from /usr/local/bin/pg_backup.config
, although I specified /etc/pg_backup.config
as config input. How can I specify from where to load the configuration?
Upvotes: 3
Views: 2062
Reputation: 80921
That script seems to accept a config file on the command line but then also requires one to exist next-to the binary itself (and finds that location in a less than robust way1).
The script is just broken.
The very first thing it does is parse its command line options (using a manual while
loop). As it does so it removes them from the positional parameters (using shift
). It stops that loop when there are no more positional parameters (when [ $# -gt 0 ]
is no longer true).
Immediately upon draining the positional parameters it then goes and checks the count of positional parameters again (if [ $# = 0 ]; then
) and when, inevitably, it finds that there are no more positional parameters it attempts to source its default configuration file.
The pg_backup_rotated.sh
script, in contrast, has a much more reasonable mechanism for loading a configuration file (though it still uses the less-than robust way of finding the location for the default config file).
Upvotes: 3