Skip to content

Commit

Permalink
fix postgresql db restore
Browse files Browse the repository at this point in the history
  • Loading branch information
monotek committed Feb 12, 2017
1 parent 55a475a commit f5cd21a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 3 additions & 3 deletions contrib/backup/functions
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function backup_db () {
if [ "${DB_ADAPTER}" == "mysql2" ]; then
mysqldump --opt --single-transaction -u${DB_USER} -p${DB_PASS} ${DB_NAME} | gzip > ${BACKUP_DIR}/${TIMESTAMP}_zammad_db.mysql.gz
elif [ "${DB_ADAPTER}" == "postgresql" ]; then
su -c "pg_dump ${DB_NAME} | gzip > ${BACKUP_DIR}/${TIMESTAMP}_zammad_db.psql.gz" postgres
su -c "pg_dump -c ${DB_NAME} | gzip > ${BACKUP_DIR}/${TIMESTAMP}_zammad_db.psql.gz" postgres
else
echo "DB ADAPTER not found. if its sqlite backup is already saved in filebackup"
fi
Expand Down Expand Up @@ -147,10 +147,10 @@ function restore_zammad () {

if [ "${DB_ADAPTER}" == "postgresql" ]; then
echo "# Restoring PostgrSQL DB"
gunzip < ${BACKUP_DIR}/${RESTORE_DB_DATE}_zammad_db.${DB_FILE_EXT}.gz | pg_restore -c ${DB_NAME}
gunzip -ck < ${BACKUP_DIR}/${RESTORE_DB_DATE}_zammad_db.${DB_FILE_EXT}.gz | su -c "psql -d ${DB_NAME}" postgres
elif [ "${DB_ADAPTER}" == "mysql2" ]; then
echo "# Restoring MySQL DB"
gunzip < ${BACKUP_DIR}/${RESTORE_DB_DATE}_zammad_db.${DB_FILE_EXT}.gz | mysql -u${DB_USER} -p${DB_PASS} ${DB_NAME}
gunzip -ck < ${BACKUP_DIR}/${RESTORE_DB_DATE}_zammad_db.${DB_FILE_EXT}.gz | mysql -u${DB_USER} -p${DB_PASS} ${DB_NAME}
fi
}

Expand Down
2 changes: 0 additions & 2 deletions contrib/backup/zammad_restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ restore_warning "${1}"

check_database_config_exists

get_db_credentials

get_restore_dates

choose_restore_date "${1}"
Expand Down

0 comments on commit f5cd21a

Please sign in to comment.