.. meta::
   :description: Patch-level update guide for Znuny LTS 7.5 — stop services, replace sources and run the migration steps to move from any 7.5.x version to a newer 7.5 patch level.
   :keywords: znuny patchlevel, patch level update, znuny 7.5 update, 7.5.x update, znuny lts, patch update, znuny upgrade

==================
Patch Level Update
==================

This documentation explains how to perform a patch level update for Znuny LTS 7.5.

.. note::   Your current system needs to be a Znuny 7.5.x where the x stands for the patch level. You can skip intermediate **patch levels**. To update from Znuny 7.3, see :doc:`update-7.5`.


Prepare
*******

Stop all services to prevent any data from changing.

.. tab-set::
  :sync-group: distribution

  .. tab-item:: RHEL based
    :sync: rhel

      .. code-block::

          systemctl stop httpd
          # Stop your local MTA, mostly Postfix, sometimes Exim or Sendmail
          systemctl stop postfix 
          # Remove crontab, stop daemon
          su -c 'bin/Cron.sh stop' - znuny
          su -c 'bin/znuny.Daemon.pl stop' - znuny

  .. tab-item:: Debian based
    :sync: debian

      .. code-block::
  
          systemctl stop apache2
          # Stop your local MTA, mostly Postfix, sometimes Exim or Sendmail
          systemctl stop postfix 
          # Remove crontab, stop daemon
          su -c 'bin/Cron.sh stop' - znuny
          su -c 'bin/znuny.Daemon.pl stop' - znuny
..


Backup
******  

Backup your system like you always do. The easiest way for small system is using the bundled backup script `scripts/backup.pl`.

Update
******

.. tab-set::
  :sync-group: distribution

  .. tab-item:: RPM installation

        All Znuny RPMs are signed. Please import our GPG key with these instructions:

        .. code-block:: bash

          curl -LO https://download.znuny.org/znuny-release-key.asc
          rpm --import znuny-release-key.asc

        .. code-block::

            rpm -Uvh https://download.znuny.org/releases/RPMS/rhel/7/znuny-7.5.1-01.noarch.rpm
            su - znuny -c 'scripts/MigrateToZnuny7_5.pl --verbose'
            su - znuny -c 'bin/znuny.Console.pl Admin::Package::ReinstallAll'
            su - znuny -c 'scripts/MigrateToZnuny7_5.pl --verbose'
            # optional upgrade of the installed addons found in configured repositories
            su - znuny -c 'bin/znuny.Console.pl Admin::Package::UpgradeAll'

            # Clear log and application cache
            su - znuny -c 'bin/znuny.Console.pl Maint::Cache::Delete'
            su - znuny -c 'bin/znuny.Console.pl Maint::Log::Clear'
        
  .. tab-item:: Source installation
    :sync: source

        .. code-block:: bash

            cd /opt
            wget https://download.znuny.org/releases/znuny-7.5.1.tar.gz
            tar -xzf znuny-7.5.1.tar.gz

            # Optional: verify the checksum of the downloaded version
            curl -LO https://download.znuny.org/releases/znuny-7.5.1.tar.gz.sha256
            sha256sum -c znuny-7.5.1.tar.gz.sha256

            # Optional: verify the GPG signature for the downloaded version, the import is only required once
            curl -LO https://download.znuny.org/znuny-release-key.asc
            gpg --import znuny-release-key.asc
            curl -LO https://download.znuny.org/releases/znuny-7.5.1.tar.gz.asc
            gpg --verify znuny-7.5.1.tar.gz.asc znuny-7.5.1.tar.gz

            # Restore Kernel/Config.pm, articles, etc.
            cp -av /opt/znuny/Kernel/Config.pm /opt/znuny-7.5.1/Kernel/
            mv /opt/znuny/var/article/* /opt/znuny-7.5.1/var/article/

            # Restore dotfiles from the homedir to the new directory
            for f in $(find -L /opt/znuny -maxdepth 1 -type f -name .\* -not -name \*.dist); do cp -av "$f" /opt/znuny-7.5.1/; done

            # Restore modified and custom cron job
            for f in $(find -L /opt/znuny/var/cron -maxdepth 1 -type f -name \* -not -name \*.dist); do cp -av "$f" /opt/znuny-7.5.1/var/cron/; done

            # Set the permissions
            znuny-7.5.1/bin/znuny.SetPermissions.pl
            ln -snf /opt/znuny-7.5.1 /opt/znuny

            su - znuny -c 'scripts/MigrateToZnuny7_5.pl --verbose'
            su - znuny -c 'bin/znuny.Console.pl Admin::Package::ReinstallAll'
            su - znuny -c 'scripts/MigrateToZnuny7_5.pl --verbose'
            # optional upgrade of the installed addons found in configured repositories
            su - znuny -c 'bin/znuny.Console.pl Admin::Package::UpgradeAll'

            # Clear log and application cache
            su - znuny -c 'bin/znuny.Console.pl Maint::Cache::Delete'
            su - znuny -c 'bin/znuny.Console.pl Maint::Log::Clear'

..


Start Znuny
***********

Start all services again. We do not start the Znuny daemon manually, instead we wait for cron starting the daemon.

.. tab-set::
  :sync-group: distribution

  .. tab-item:: RHEL based
    :sync: rhel

      .. code-block::

          systemctl start httpd
          # Start your local MTA, mostly Postfix, sometimes Exim or Sendmail
          systemctl start postfix 
          # Create Znuny's crontab to start the daemon
          su -c 'bin/Cron.sh start' - znuny

  .. tab-item:: Debian based
    :sync: debian

      .. code-block::
  
          systemctl start apache2
          # Start your local MTA, mostly Postfix, sometimes Exim or Sendmail
          systemctl start postfix 
          # Create Znuny's crontab to start the daemon
          su -c 'bin/Cron.sh start' - znuny

..
