Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #16 from gzarkadas/master

Fixes for gettext make process and postgresql database backup method
  • Loading branch information...
commit 22e8e3874056aa83206211436186dc285709f432 2 parents 72b93f0 + a1521de
@kissifrot kissifrot authored
Showing with 38 additions and 14 deletions.
  1. +32 −11 lib/backup-methods.sh
  2. +6 −3 po/Makefile
View
43 lib/backup-methods.sh
@@ -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"
@@ -915,7 +932,7 @@ 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
@@ -923,9 +940,13 @@ function backup_method_pgsql()
# 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
}
@@ -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
View
9 po/Makefile
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.