Skip to content

Commit

Permalink
Merge pull request #16 from gzarkadas/master
Browse files Browse the repository at this point in the history
Fixes for gettext make process and postgresql database backup method
  • Loading branch information
kissifrot committed Dec 26, 2011
2 parents 72b93f0 + a1521de commit 22e8e38
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 14 deletions.
43 changes: 32 additions & 11 deletions lib/backup-methods.sh
Expand Up @@ -885,26 +885,43 @@ function backup_method_pgsql()
debug "backup_method_pgsql ($method)"

info "Using method \"\$method\"."
if [[ ! -x $pgdump ]]; then
error "The \"pgsql\" method is chosen, but \$pgdump is not found."
if [[ -x $pgdump ]] && [[ -x ${pgdump}all ]]; then
:
else
error "The \"postgresql\" method is chosen, but \$pgdump and/or \$pgdumpall are not found."
fi

opt=" -U$BM_PGSQL_ADMINLOGIN -h$BM_PGSQL_HOST -p$BM_PGSQL_PORT"
# Allow empty host when connecting to postgress with unix sockets.

if [[ "X$BM_PGSQL_HOST" = "X" ]]; then
BM_PGSQL_HOSTFLAGS=""
else
BM_PGSQL_HOSTFLAGS="-h$BM_PGSQL_HOST"
fi
opt=" -U$BM_PGSQL_ADMINLOGIN $BM_PGSQL_HOSTFLAGS -p$BM_PGSQL_PORT"

# We need a second variable, to know if the backup pgpass file was used.

BM_SHOULD_PURGE_PGPASS="false"
BM_USING_BACKUP_PGPASS="false"

if [[ -f $pgsql_conffile ]]; then
info "Found existing PgSQL client configuration file: \$pgsql_conffile"
info "Looking for matching credentials in this file..."
if ! grep -qE "(${BM_PGSQL_HOST}|[^:]*):(${BM_PGSQL_PORT}|[^:]*):[^:]*:${BM_PGSQL_ADMINLOGIN}:${BM_PGSQL_ADMINPASS}" $pgsql_conffile; then
info "No matching credentials: inserting our own."
cp $pgsql_conffile $pgsql_conffile_bm
BM_SHOULD_PURGE_PGPASS="true"
echo "${BM_PGSQL_HOST}:${BM_PGSQL_PORT}:${BM_PGSQL_ADMINLOGIN}:${BM_PGSQL_ADMINPASS}" >> $pgsql_conffile
BM_USING_BACKUP_PGPASS="true"
mv $pgsql_conffile $pgsql_conffile_bm
touch $pgsql_conffile
chmod 0600 $pgsql_conffile
echo "${BM_PGSQL_HOST}:${BM_PGSQL_PORT}:*:${BM_PGSQL_ADMINLOGIN}:${BM_PGSQL_ADMINPASS}" >> $pgsql_conffile
fi
else
warning "Creating a default PgSQL client configuration file: \$HOME/.pgpass"
echo "${BM_PGSQL_HOST}:${BM_PGSQL_PORT}:${BM_PGSQL_ADMINLOGIN}:${BM_PGSQL_ADMINPASS}" >> $pgsql_conffile
touch $pgsql_conffile
chmod 0600 $pgsql_conffile
echo "${BM_PGSQL_HOST}:${BM_PGSQL_PORT}:*:${BM_PGSQL_ADMINLOGIN}:${BM_PGSQL_ADMINPASS}" >> $pgsql_conffile
fi

compress="$BM_PGSQL_FILETYPE"
Expand All @@ -915,17 +932,21 @@ function backup_method_pgsql()
file_to_create="$BM_REPOSITORY_ROOT/${BM_ARCHIVE_PREFIX}-all-pgsql-databases.$TODAY.sql"
command="${pgdump}all $opt $BM_PGSQL_EXTRA_OPTIONS"
else
file_to_create="$BM_REPOSITORY_ROOT/${BM_ARCHIVE_PREFIX}-${database}.$TODAY.sql"
file_to_create="$BM_REPOSITORY_ROOT/${BM_ARCHIVE_PREFIX}-pgsql-${database}.$TODAY.sql"
command="$pgdump $opt $database $BM_PGSQL_EXTRA_OPTIONS"
fi
__create_file_with_meta_command
done

# purge the .pgpass file, if created by Backup Manager
if [[ "$BM_SHOULD_PURGE_PGPASS" == "true" ]]; then
info "restoring initial .pgpass file."
warning "To avoid problems with .pgpass, insert the configured host:port:user:pass in $pgsql_conffile"
mv $pgsql_conffile_bm $pgsql_conffile
info "Removing default PostgreSQL password file: \$pgsql_conffile"
rm -f $pgsql_conffile
if [[ "$BM_USING_BACKUP_PGPASS" == "true" ]]; then
info "restoring initial \$pgsql_conffile file from backup."
warning "To avoid problems with \$pgsql_conffile, insert the configured host:port:database:user:password inside."
mv $pgsql_conffile_bm $pgsql_conffile
fi
fi
}

Expand Down Expand Up @@ -969,7 +990,7 @@ function backup_method_mysql()
file_to_create="$BM_REPOSITORY_ROOT/${BM_ARCHIVE_PREFIX}-all-mysql-databases.$TODAY.sql"
command="$base_command --all-databases"
else
file_to_create="$BM_REPOSITORY_ROOT/${BM_ARCHIVE_PREFIX}-${database}.$TODAY.sql"
file_to_create="$BM_REPOSITORY_ROOT/${BM_ARCHIVE_PREFIX}-mysql-${database}.$TODAY.sql"
command="$base_command $database"
fi
__create_file_with_meta_command
Expand Down
9 changes: 6 additions & 3 deletions po/Makefile
Expand Up @@ -38,13 +38,16 @@ clean:
backup-manager.files \
$(MOFILES) \
messages messages.mo \
messages.po

messages.po
for file in $(wildcard *.old); do \
mv -f $$file `echo $$file | sed 's/\.old//'`; \
done

.po.mo: backup-manager.pot
@echo "Merging $(PACKAGE).pot and $*.po"
@msgmerge $*.po $(PACKAGE).pot -o $*.po.new
@if [ "`diff $*.po $*.po.new | grep '[<>]' | wc -l`" -ne 2 ]; then \
mv -f $*.po.new $*.po; \
mv -f --backup=simple --suffix='.old' $*.po.new $*.po; \
else \
rm -f $*.po.new; \
fi
Expand Down

0 comments on commit 22e8e38

Please sign in to comment.