Commits

Zhang Huangbin committed 5662d72

Fixed: Incorrect PGSQL_SYS_USER in tools/backup_pgsql.sh.

Comments (0)

Files changed (2)

iRedMail/functions/cleanup.sh

         chown ${SYS_ROOT_USER}:${SYS_ROOT_GROUP} ${BACKUP_SCRIPT_PGSQL}
         chmod 0700 ${BACKUP_SCRIPT_PGSQL}
 
+        perl -pi -e 's#^(export PGSQL_SYS_USER=).*#${1}"$ENV{PGSQL_SYS_USER}"#' ${BACKUP_SCRIPT_PGSQL}
         perl -pi -e 's#^(export BACKUP_ROOTDIR=).*#${1}"$ENV{BACKUP_DIR}"#' ${BACKUP_SCRIPT_PGSQL}
         perl -pi -e 's#^(export DATABASES=).*#${1}"$ENV{PGSQL_BACKUP_DATABASES}"#' ${BACKUP_SCRIPT_PGSQL}
 

iRedMail/tools/backup_pgsql.sh

 #########################################################
 # Modify below variables to fit your need ----
 #########################################################
-# Administrator user name. Usually, it's postgres.
-# FreeBSD: pgsql
-# OpenBSD: _postgresql
-export PGSQL_ROOT_USER='_postgresql'
+# System user used to run PostgreSQL daemon.
+#   - On Linux, it's postgres.
+#   - On FreeBSD, it's pgsql.
+#   - On OpenBSD, it's _postgresql.
+export PGSQL_SYS_USER='postgres'
 
 # Where to store backup copies.
 export BACKUP_ROOTDIR='/var/vmail/backup'
 # Check and create directories.
 [ ! -d ${BACKUP_DIR} ] && mkdir -p ${BACKUP_DIR} 2>/dev/null
 
-# Get HOME directory of PGSQL_ROOT_USER
-export PGSQL_ROOT_USER_HOME="$(su - ${PGSQL_ROOT_USER} -c 'echo $HOME')"
+# Get HOME directory of PGSQL_SYS_USER
+export PGSQL_SYS_USER_HOME="$(su - ${PGSQL_SYS_USER} -c 'echo $HOME')"
 
 # Initialize log file.
-echo "* Starting backup: ${TIMESTAMP}." >${LOGFILE}
+echo "* Starting at: ${YEAR}-${MONTH}-${DAY}-${TIME}." >${LOGFILE}
 echo "* Backup directory: ${BACKUP_DIR}." >>${LOGFILE}
 
 # Backup.
     output_sql="${db}-${TIMESTAMP}.sql"
 
     # Verify db existence
-    su - "${PGSQL_ROOT_USER}" -c "psql -d ${db} -c '\q' >/dev/null 2>&1"
+    su - "${PGSQL_SYS_USER}" -c "psql -d ${db} -c '\q' >/dev/null 2>&1"
 
     # Dump
     if [ X"$?" == X'0' ]; then
-        su - "${PGSQL_ROOT_USER}" -c "${CMD_PG_DUMP} ${db} > ${PGSQL_ROOT_USER_HOME}/${output_sql}"
+        su - "${PGSQL_SYS_USER}" -c "${CMD_PG_DUMP} ${db} > ${PGSQL_SYS_USER_HOME}/${output_sql}"
 
         # Move to backup directory.
-        mv ${PGSQL_ROOT_USER_HOME}/${output_sql} ${BACKUP_DIR}
+        mv ${PGSQL_SYS_USER_HOME}/${output_sql} ${BACKUP_DIR}
 
         # Compress
         if [ X"${COMPRESS}" == X"YES" ]; then
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.