functions 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. #!/usr/bin/env bash
  2. #
  3. # Zammad backup script functions
  4. #
  5. function demand_backup_conf () {
  6. if [ -f "${BACKUP_SCRIPT_PATH}/config" ]; then
  7. # Ensure we're inside of our Backup-Script folder (see issue 2508)
  8. # shellcheck disable=SC2164
  9. cd "${BACKUP_SCRIPT_PATH}"
  10. # import config
  11. . ${BACKUP_SCRIPT_PATH}/config
  12. else
  13. echo -e "\n The 'config' file is missing!"
  14. echo -e " Please copy ${BACKUP_SCRIPT_PATH}/config.dist to ${BACKUP_SCRIPT_PATH}/config before running $0!\n"
  15. echo -e " Learn more about the backup configuration at https://docs.zammad.org/en/latest/appendix/backup-and-restore/configuration.html"
  16. exit 1
  17. fi
  18. # Check if filesystem full dump setting exists and fall back if not
  19. if [ -z ${FULL_FS_DUMP+x} ]; then
  20. # Falling back to old default behavior
  21. FULL_FS_DUMP='yes'
  22. if [ "${DEBUG}" == "yes" ]; then
  23. echo "FULL_FS_DUMP is not set, falling back to 'yes' to produce a full backup."
  24. fi
  25. fi
  26. }
  27. function get_zammad_dir () {
  28. ZAMMAD_DIR="$(echo ${BACKUP_SCRIPT_PATH} | sed -e 's#/contrib/backup.*##g')"
  29. }
  30. function get_backup_date () {
  31. TIMESTAMP="$(date +'%Y%m%d%H%M%S')"
  32. if [ "${DEBUG}" == "yes" ]; then
  33. echo "timestamp is ${TIMESTAMP}"
  34. fi
  35. }
  36. function delete_old_backups () {
  37. # Use -mmin to clean up files as -mtime (days) is too unprecise.
  38. # However, add +60 minutes to allow for the backup script run time, so that
  39. # backups created a few minutes more than a day ago are not already purged.
  40. test -d ${BACKUP_DIR} && find ${BACKUP_DIR}/*_zammad_*.gz -type f -mmin +$(((60*24)*${HOLD_DAYS}+60)) -delete
  41. }
  42. function get_db_credentials () {
  43. DB_ADAPTER="$(grep -m 1 '^[[:space:]]*adapter:' < ${ZAMMAD_DIR}/config/database.yml | sed -e 's/.*adapter:[[:space:]]*//g')"
  44. DB_HOST="$(grep -m 1 '^[[:space:]]*host:' < ${ZAMMAD_DIR}/config/database.yml | sed -e 's/.*host:[[:space:]]*//g')"
  45. DB_PORT="$(grep -m 1 '^[[:space:]]*port:' < ${ZAMMAD_DIR}/config/database.yml | sed -e 's/.*port:[[:space:]]*//g')"
  46. DB_NAME="$(grep -m 1 '^[[:space:]]*database:' < ${ZAMMAD_DIR}/config/database.yml | sed -e 's/.*database:[[:space:]]* //g')"
  47. DB_USER="$(grep -m 1 '^[[:space:]]*username:' < ${ZAMMAD_DIR}/config/database.yml | sed -e 's/.*username:[[:space:]]*//g')"
  48. DB_PASS="$(grep -m 1 '^[[:space:]]*password:' < ${ZAMMAD_DIR}/config/database.yml | sed -e 's/.*password:[[:space:]]*//g')"
  49. if [ "${DB_ADAPTER}" == "postgresql" ]; then
  50. # Ensure that HOST and PORT are not empty, provide defaults if needed.
  51. if [ "${DB_HOST}x" == "x" ]; then
  52. DB_HOST="localhost"
  53. fi
  54. if [ "${DB_PORT}x" == "x" ]; then
  55. DB_PORT="5432"
  56. fi
  57. fi
  58. if [ "${DEBUG}" == "yes" ]; then
  59. echo "adapter=${DB_ADAPTER} dbhost=${DB_HOST} dbport=${DB_PORT} dbname=${DB_NAME} dbuser=${DB_USER} dbpass=${DB_PASS}"
  60. fi
  61. }
  62. function backup_dir_create () {
  63. test -d ${BACKUP_DIR} || mkdir -p ${BACKUP_DIR}
  64. state=$?
  65. if [ "${state}" == "1" ]; then
  66. echo -e "\n\n # ERROR(${state}) - Creation of backup directory failed. Please double check permissions."
  67. echo -e " #-> BACKUP WAS NOT SUCCESSFUL"
  68. exit 3
  69. fi
  70. if [ "${DEBUG}" == "yes" ]; then
  71. echo "backup dir is ${BACKUP_DIR}"
  72. fi
  73. }
  74. backup_file_write_test () {
  75. # We're testing if we can actually write into the provided directory with
  76. # the current user before continuing.
  77. touch ${BACKUP_DIR}/write_test 2> /dev/null
  78. state=$?
  79. if [ "${state}" == "1" ]; then
  80. # We're checking for critical restoration errors
  81. # It may not cover all possible errors which is out of scope of this script
  82. echo -e "\n\n # ERROR(${state}) - Creation of backup files was not possible. Double check permissions."
  83. echo -e " #-> BACKUP WAS NOT SUCCESSFUL"
  84. exit 3
  85. fi
  86. rm -f ${BACKUP_DIR}/write_test
  87. }
  88. backup_file_read_test () {
  89. # We're testing if we can read the provided file names before
  90. # starting. Other wise handling would be more difficult depending on
  91. # the installation type
  92. if [ "${DEBUG}" == "yes" ]; then
  93. echo "I've been looking for these backup files: "
  94. echo "- ${BACKUP_DIR}/${RESTORE_FILE_DATE}_zammad_files.tar.gz"
  95. echo "- ${BACKUP_DIR}/${RESTORE_DB_DATE}_zammad_db.${DB_FILE_EXT}.gz"
  96. fi
  97. if [[ (! -r "${BACKUP_DIR}/${RESTORE_FILE_DATE}_zammad_files.tar.gz") || (! -r "${BACKUP_DIR}/${RESTORE_DB_DATE}_zammad_db.${DB_FILE_EXT}.gz") ]]; then
  98. echo -e "\n\n # ERROR - Cannot read on or more of my backup files. Double check permissions."
  99. echo -e " #-> RESTORE WAS NOT SUCCESSFUL"
  100. exit 3
  101. fi
  102. }
  103. function check_empty_password () {
  104. if [ "${DB_PASS}x" == "x" ]; then
  105. echo "# ERROR - Found an empty database password ..."
  106. echo "# - This may be intended or not, however - this script does not support this."
  107. echo "# - If you don't know how to continue, consult https://docs.zammad.org/en/latest/appendix/backup-and-restore/index.html"
  108. exit 2
  109. fi
  110. }
  111. function backup_files () {
  112. echo "creating file backup..."
  113. if [ "${FULL_FS_DUMP}" == 'yes' ]; then
  114. echo " ... as full dump"
  115. tar -C / -czf ${BACKUP_DIR}/${TIMESTAMP}_zammad_files.tar.gz\
  116. --exclude='tmp' --exclude 'node_modules' --exclude '.git' --exclude '.yarn/cache' --exclude='config/database.yml' ${ZAMMAD_DIR#/}
  117. state=$?
  118. else
  119. echo " ... only with productive data (attachments)"
  120. if [ ! -d "${ZAMMAD_DIR}/storage/" ]; then
  121. # Admin has requested an attachment backup only, however, there is no storage
  122. # directory. We'll warn Mr.Admin and create the directory as workaround.
  123. echo " ... WARNING: You don't seem to have any attachments in the file system!"
  124. echo " ... Please consult https://docs.zammad.org/en/latest/appendix/backup-and-restore/troubleshooting.html"
  125. echo " ... Creating empty storage directory so the backup can continue ..."
  126. mkdir -p ${ZAMMAD_DIR}/storage/
  127. chown -R zammad:zammad ${ZAMMAD_DIR}/storage/
  128. fi
  129. if [ -h ${ZAMMAD_DIR}/storage ]; then
  130. echo "... Found symlink, will store both Symlink and Symlink target ..."
  131. REALDIR=$(realpath ${ZAMMAD_DIR}/storage/)
  132. ZAMMAD_STORAGE_DIR="${ZAMMAD_DIR#/}/storage ${REALDIR#/}"
  133. else
  134. ZAMMAD_STORAGE_DIR="${ZAMMAD_DIR#/}/storage/"
  135. fi
  136. tar -C / -czf ${BACKUP_DIR}/${TIMESTAMP}_zammad_files.tar.gz ${ZAMMAD_STORAGE_DIR} ${ZAMMAD_DIR#/}/var/
  137. state=$?
  138. fi
  139. if [ $state == '2' ]; then
  140. echo "# ERROR(2) - File backup reported a fatal error."
  141. echo "- Check file permissions and try again."
  142. echo -e " \n# BACKUP WAS NOT SUCCESSFUL"
  143. exit 1
  144. fi
  145. if [ $state == '1' ]; then
  146. echo "# WARNING - Files have changed during backup."
  147. echo "- This indicates your Zammad instance is running and thus may be normal."
  148. fi
  149. ln -sfn ${BACKUP_DIR}/${TIMESTAMP}_zammad_files.tar.gz ${BACKUP_DIR}/latest_zammad_files.tar.gz
  150. }
  151. function create_pgpassfile() {
  152. PGPASSFILE=$(mktemp)
  153. export PGPASSFILE
  154. chmod 600 "$PGPASSFILE"
  155. cat <<EOT > "$PGPASSFILE"
  156. *:*:${DB_NAME}:${DB_USER}:${DB_PASS}
  157. EOT
  158. trap 'rm "$PGPASSFILE"' EXIT
  159. }
  160. function backup_db () {
  161. if [ "${DB_ADAPTER}" == "mysql2" ]; then
  162. echo "creating mysql backup..."
  163. mysqldump --opt --single-transaction -u${DB_USER} -p${DB_PASS} ${DB_NAME} | gzip > ${BACKUP_DIR}/${TIMESTAMP}_zammad_db.mysql.gz
  164. ln -sfn ${BACKUP_DIR}/${TIMESTAMP}_zammad_db.mysql.gz ${BACKUP_DIR}/latest_zammad_db.mysql.gz
  165. elif [ "${DB_ADAPTER}" == "postgresql" ]; then
  166. echo "creating postgresql backup..."
  167. create_pgpassfile
  168. pg_dump --dbname "${DB_NAME}" \
  169. --username "${DB_USER}" \
  170. ${DB_HOST:+--host $DB_HOST} \
  171. ${DB_PORT:+--port $DB_PORT} \
  172. --no-privileges --no-owner \
  173. --compress 6 --file "${BACKUP_DIR}/${TIMESTAMP}_zammad_db.psql.gz"
  174. state=$?
  175. if [ "${state}" == "1" ]; then
  176. # We're checking for critical restoration errors
  177. # It may not cover all possible errors which is out of scope of this script
  178. echo -e "\n\n # ERROR(${state}) - Database credentials are wrong or database server configuration is invalid."
  179. echo -e " #-> BACKUP WAS NOT SUCCESSFUL"
  180. exit 2
  181. fi
  182. ln -sfn ${BACKUP_DIR}/${TIMESTAMP}_zammad_db.psql.gz ${BACKUP_DIR}/latest_zammad_db.psql.gz
  183. else
  184. echo -e "\n\n # ERROR - Database type or database.yml incorrect. Unsupported database type found."
  185. echo -e " #-> BACKUP WAS NOT SUCCESSFUL"
  186. exit 2
  187. fi
  188. }
  189. function backup_chmod_dump_data () {
  190. echo "Ensuring dump permissions ..."
  191. chmod 600 ${BACKUP_DIR}/${TIMESTAMP}_zammad_db.psql.gz ${BACKUP_DIR}/${TIMESTAMP}_zammad_files.tar.gz
  192. }
  193. function check_database_config_exists () {
  194. if [ -f ${ZAMMAD_DIR}/config/database.yml ]; then
  195. get_db_credentials
  196. else
  197. echo -e "${ZAMMAD_DIR}/config/database.yml is missing. is Zammad configured yet? \nAborting..."
  198. exit 1
  199. fi
  200. }
  201. function restore_warning () {
  202. if [ -n "${1}" ]; then
  203. CHOOSE_RESTORE="yes"
  204. else
  205. echo -e "The restore will delete your current database! \nBe sure to have a backup available! \n"
  206. echo -e "Please ensure to have twice the storage of the uncompressed backup size! \n\n"
  207. echo -e "Note that the restoration USUALLY requires root permissions as services are stopped! \n\n"
  208. echo -e "Enter 'yes' if you want to proceed!"
  209. read -p 'Restore?: ' CHOOSE_RESTORE
  210. fi
  211. if [ "${CHOOSE_RESTORE}" != "yes" ]; then
  212. echo "Restore aborted!"
  213. exit 1
  214. fi
  215. }
  216. function db_helper_warning () {
  217. echo -e " # WARNING: THIS SCRIPT CHANGES CREDENTIALS, DO NOT CONTINUE IF YOU DON'T KNOW WHAT YOU'RE DOING! \n\n"
  218. echo -e " Limitations:"
  219. echo -e " - only works for local postgresql installations"
  220. echo -e " - only works for postgresql\n"
  221. echo -e "Enter 'yes' if you want to proceed!"
  222. read -p 'ALTER zammad users password?: ' DB_HELPER
  223. if [ "${DB_HELPER}" != "yes" ]; then
  224. echo "Helper script aborted!"
  225. exit 1
  226. fi
  227. }
  228. function get_restore_dates () {
  229. RESTORE_FILE_DATES="$(find ${BACKUP_DIR} -type f -iname '*_zammad_files.tar.gz' | sed -e "s#${BACKUP_DIR}/##g" -e "s#_zammad_files.tar.gz##g" | sort)"
  230. if [ "${DB_ADAPTER}" == "postgresql" ]; then
  231. DB_FILE_EXT="psql"
  232. elif [ "${DB_ADAPTER}" == "mysql2" ]; then
  233. DB_FILE_EXT="mysql"
  234. fi
  235. RESTORE_DB_DATES="$(find ${BACKUP_DIR} -type f -iname "*_zammad_db.${DB_FILE_EXT}.gz" | sed -e "s#${BACKUP_DIR}/##g" -e "s#_zammad_db.${DB_FILE_EXT}.gz##g" | sort)"
  236. }
  237. function choose_restore_date () {
  238. if [ -n "${1}" ]; then
  239. RESTORE_FILE_DATE="${1}"
  240. else
  241. echo -e "Enter file date to restore: \n${RESTORE_FILE_DATES}"
  242. read -p 'File date: ' RESTORE_FILE_DATE
  243. fi
  244. if [ ! -f "${BACKUP_DIR}/${RESTORE_FILE_DATE}_zammad_files.tar.gz" ];then
  245. echo -e "File ${BACKUP_DIR}/${RESTORE_FILE_DATE}_zammad_files.tar.gz does not exist! \nRestore aborted!"
  246. exit 1
  247. fi
  248. if [ -n "${1}" ]; then
  249. RESTORE_DB_DATE="${1}"
  250. else
  251. echo -e "Enter db date to restore: \n${RESTORE_DB_DATES}"
  252. read -p 'DB date: ' RESTORE_DB_DATE
  253. fi
  254. if [ ! -f "${BACKUP_DIR}/${RESTORE_DB_DATE}_zammad_db.${DB_FILE_EXT}.gz" ];then
  255. echo -e "File ${BACKUP_DIR}/${RESTORE_DB_DATE}_zammad_db.${DB_FILE_EXT}.gz does not exist! \nRestore aborted!"
  256. exit 1
  257. fi
  258. }
  259. function detect_initcmd () {
  260. if [ -n "$(which systemctl 2> /dev/null)" ]; then
  261. INIT_CMD="systemctl"
  262. elif [ -n "$(which initctl 2> /dev/null)" ]; then
  263. INIT_CMD="initctl"
  264. else
  265. function sysvinit () {
  266. service $2 $1
  267. }
  268. INIT_CMD="sysvinit"
  269. fi
  270. if [ "${DOCKER}" == "yes" ]; then
  271. INIT_CMD="initctl"
  272. fi
  273. if [ "${DEBUG}" == "yes" ]; then
  274. echo "INIT CMD = ${INIT_CMD}"
  275. fi
  276. }
  277. function start_zammad () {
  278. echo "# Starting Zammad"
  279. ${INIT_CMD} start zammad
  280. }
  281. function stop_zammad () {
  282. echo "# Stopping Zammad"
  283. ${INIT_CMD} stop zammad
  284. if [ "$?" != "0" ]; then
  285. echo -e "\n\n # WARNING: You don't seem to have administrative permissions!"
  286. echo -e " #-> This may be fine if you're on a source code installation."
  287. echo -e " #-> Please ensure that Zammad is NOT running - otherwise restore will FAIL.\n"
  288. fi
  289. }
  290. function restore_zammad () {
  291. if ! command -v zammad > /dev/null; then
  292. # See #3160 for the reasons of this :>
  293. restore_files
  294. fi
  295. if [ "${DB_ADAPTER}" == "postgresql" ]; then
  296. echo "# Checking requirements"
  297. if ! id "zammad" &> /dev/null; then
  298. echo "# ERROR: User 'zammad' is not present, but should be by default! #"
  299. echo "# Restoration was NOT successful, exiting ..."
  300. exit 1
  301. fi
  302. echo "# ... Dropping current database ${DB_NAME}"
  303. # This step is only needed for some pgsql dumps, as they don't provide a drop table statement which will cause
  304. # relation errors during restoration (as on package installation there's always an initialized database)
  305. if command -v zammad > /dev/null; then
  306. zammad config:set DISABLE_DATABASE_ENVIRONMENT_CHECK=1
  307. zammad run rake db:drop
  308. zammad config:set DISABLE_DATABASE_ENVIRONMENT_CHECK=0
  309. else
  310. DISABLE_DATABASE_ENVIRONMENT_CHECK=1 ${ZAMMAD_DIR}/bin/rake db:drop
  311. fi
  312. echo "# ... Creating database ${DB_NAME} for owner ${DB_USER}"
  313. if command -v zammad > /dev/null; then
  314. # We'll skip this part for docker installations
  315. su -c "psql -c \"CREATE DATABASE ${DB_NAME} OWNER ${DB_USER};\"" postgres
  316. else
  317. ${ZAMMAD_DIR}/bin/rake db:create
  318. fi
  319. echo "# Restoring PostgreSQL DB"
  320. create_pgpassfile
  321. # We're removing uncritical dump information that caused "ugly" error
  322. # messages on older script versions. These could safely be ignored.
  323. zcat ${BACKUP_DIR}/${RESTORE_DB_DATE}_zammad_db.${DB_FILE_EXT}.gz | \
  324. sed '/^CREATE EXTENSION IF NOT EXISTS plpgsql/d'| \
  325. sed '/^COMMENT ON EXTENSION plpgsql/d'| \
  326. psql -q -b -o /dev/null \
  327. ${DB_HOST:+--host $DB_HOST} ${DB_PORT:+--port $DB_PORT} ${DB_USER:+--username $DB_USER} --dbname ${DB_NAME}
  328. state=$?
  329. if [[ ("${state}" == "1") || ( "${state}" == "2") || ( "${state}" == "3") ]]; then
  330. # We're checking for critical restoration errors
  331. # It may not cover all possible errors which is out of scope of this script
  332. echo -e "\n\n # ERROR(${state}) - Database credentials are wrong or database server configuration is invalid."
  333. echo -e " #-> RESTORE WAS NOT SUCCESSFUL"
  334. exit 2
  335. fi
  336. elif [ "${DB_ADAPTER}" == "mysql2" ]; then
  337. echo "# Restoring MySQL DB"
  338. zcat < ${BACKUP_DIR}/${RESTORE_DB_DATE}_zammad_db.${DB_FILE_EXT}.gz | mysql -u${DB_USER} -p${DB_PASS} ${DB_NAME}
  339. state=$?
  340. if [ "${state}" != "0" ]; then
  341. echo -e "\n\n # ERROR(${state}) - Database credentials are wrong or database server configuration is invalid."
  342. echo -e " #-> RESTORE WAS NOT SUCCESSFUL"
  343. exit 2
  344. fi
  345. else
  346. echo -e "\n\n # ERROR - Database type or database.yml incorrect. Unsupported database type found."
  347. echo -e " #-> RESTORE WAS NOT SUCCESSFUL"
  348. exit 2
  349. fi
  350. if command -v zammad > /dev/null; then
  351. # See #3160 for the reasons of this :>
  352. restore_files
  353. fi
  354. # Ensure all data is loaded from the restored database and not the cache of the previous system state
  355. echo "# Clearing Cache ..."
  356. if command -v zammad > /dev/null; then
  357. zammad run rails r "Rails.cache.clear"
  358. else
  359. ${ZAMMAD_DIR}/bin/rails r "Rails.cache.clear"
  360. fi
  361. }
  362. function restore_files () {
  363. echo "# Restoring Files"
  364. tar -C / --overwrite -xzf ${BACKUP_DIR}/${RESTORE_FILE_DATE}_zammad_files.tar.gz
  365. state=$?
  366. if [[ ($state == '1') || ($state == '2') ]]; then
  367. echo "# ERROR(${state}) - File restore reported an error."
  368. echo "- Check file permissions, and ensure Zammad IS NOT running, and try again."
  369. echo -e " \n# RESTORE WAS NOT SUCCESSFUL"
  370. exit 1
  371. fi
  372. echo "# Ensuring correct file permissions ..."
  373. chown -R zammad:zammad ${ZAMMAD_DIR}
  374. }
  375. function kind_exit () {
  376. # We're nice to our admin and bring Zammad back up before exiting
  377. start_zammad
  378. exit 1
  379. }
  380. function db_helper_alter_user () {
  381. # Get DB credentials
  382. get_db_credentials
  383. if [ "${DB_PASS}x" == "x" ]; then
  384. echo "# Found an empty password - I'll be fixing this for you ..."
  385. DB_PASS="$(tr -dc A-Za-z0-9 < /dev/urandom | head -c10)"
  386. sed -e "s/.*adapter:.*/ adapter: ${DB_ADAPTER}/" \
  387. -e "s/.*username:.*/ username: ${DB_USER}/" \
  388. -e "s/.*password:.*/ password: ${DB_PASS}/" \
  389. -e "s/.*database:.*/ database: ${DB_NAME}/" < ${ZAMMAD_DIR}/contrib/packager.io/database.yml.pkgr > ${ZAMMAD_DIR}/config/database.yml
  390. echo "# ... Fixing permission database.yml"
  391. chown zammad:zammad ${ZAMMAD_DIR}/config/database.yml
  392. fi
  393. if [ "${DB_USER}x" == "x" ]; then
  394. echo "ERROR - Your configuration file does not seem to contain a username."
  395. echo "Aborting the script - double check your installation."
  396. kind_exit
  397. fi
  398. if [ "${DB_ADAPTER}" == "postgresql" ]; then
  399. if [[ ("${DB_HOST}" == "localhost") || "${DB_HOST}" == "127.0.0.1" || "${DB_HOST}" == "::1" ]]; then
  400. # Looks like a local pgsql installation - let's continue
  401. su -c "psql -c \"ALTER USER ${DB_USER} WITH PASSWORD '${DB_PASS}';\"" postgres
  402. state=$?
  403. else
  404. echo "You don't seem to be using a local PostgreSQL installation."
  405. echo "This script does not support your installation. No changes were done."
  406. kind_exit
  407. fi
  408. else
  409. echo "You don't seem to use PostgreSQL. This script does not support your installation."
  410. echo "No changes were done."
  411. kind_exit
  412. fi
  413. if [ "${state}" != "0" ]; then
  414. echo "ERROR - Our previous command returned an unhandled error code."
  415. echo "Check above command output. Please consult https://community.zammad.org if you can't solve this issue on your own."
  416. kind_exit
  417. fi
  418. }
  419. function start_backup_message () {
  420. echo -e "\n# Zammad backup started - $(date)!\n"
  421. }
  422. function start_restore_message () {
  423. echo -e "\n# Zammad restore started - $(date)!\n"
  424. }
  425. function start_helper_message () {
  426. echo -e "\n # This helper script sets the current Zammad user password on your postgresql server."
  427. }
  428. function finished_backup_message () {
  429. echo -e "\n# Zammad backuped successfully - $(date)!\n"
  430. }
  431. function finished_restore_message () {
  432. echo -e "\n# Zammad restored successfully - $(date)!\n"
  433. }