CentOS 7.x Update lightsail owncloud instance in-place

From Notes_Wiki
Revision as of 11:59, 29 September 2020 by Saurabh (talk | contribs) (Created page with "<yambe:breadcrumb self="Update lightsail owncloud instance in-place">CentOS 7.x Setup lightsail instances|Setup lightsail instances</yambe:breadcrumb> =CentOS 7.x Update light...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<yambe:breadcrumb self="Update lightsail owncloud instance in-place">CentOS 7.x Setup lightsail instances|Setup lightsail instances</yambe:breadcrumb>

CentOS 7.x Update lightsail owncloud instance in-place

  1. ssh to VM
  2. Upgrade packages:
    yum -y install vim epel-release wget
    yum -y install perl-Data-Dumper byobu
  3. Download latest bitnami owncloud installer from https://bitnami.com/stack/owncloud/installer
  4. Stop old owncloud instance
    cd /opt/owncloud-<old-version>
    ./ctlscript.sh stop
  5. disable access to ports 80, 443 temporarily via firewall if possible.
  6. Install latest stack
    cd /root/
    chmod +x bitnami*
    ./bitnami-*
  7. Validate swap is available or else add it using CentOS 7.x adding swap space using file
  8. Various options while installing
    Folder
    /opt/owncloud-<version> (Default)
    Real name
    admin
    Email address
    saurabh [at] sbarjatiya.com
    Login
    admin
    Password, Retype password
    Something simple (Will get overwritten during DB restore anyway)
    Hostname [127.0.0.1]
    files.sbarjatiya.com
    Email support
    Y(Custom, saurabh [at] sbarjatiya.com, <secret>, mail.sbarjatiya.com, 587, TLS)
    Settings
    Production
    Continue with installation
    Yes
  9. Stop latest installed stack using
    cd /opt/owncloud-<new-version>
    ./ctlscript.sh stop
  10. Only start mysql of old stack using following and take latest database dump
    cd /opt/owncloud-<old-version>
    ./ctlscript.sh start mysql
    cat apps/owncloud/htdocs/config/config.php #Note database parameters
    mysql/bin/mysqldump -u bn_owncloud -p<db-password> bitnami_owncloud > /root/latest-bitnami-owncloud.sql
    ./ctlscript.sh stop mysql
  11. Restore database on latest stack using following steps:
    cd /opt/owncloud-<new-version>
    ./ctlscript.sh start mysql
    cat apps/owncloud/htdocs/config/config.php #Note database parameters
    mysql/bin/mysql -u bn_owncloud -pea5042a4c8 bitnami_owncloud < /root/latest-bitnami-owncloud.sql
  12. Move data files to new owncloud instance
    mkdir /root/new-temp-data
    mv /opt/owncloud-<new-version>/apps/owncloud/data/* /root/new-temp-data/
    We must keep /opt/owncloud-<old-version>/apps/owncloud/data/ as it is. Then edit /opt/owncloud-<new-version>/apps/owncloud/htdocs/config/config.php to point datadirectory to previous datadirectory. Note that datadirectory is hard coded inside the MySQL DB. Hence, we cannot change the path easily without modifying large no. of MySQL table rows.
    Note that folder /opt/owncloud-<old-version>/apps/owncloud/data contains critical .htaccess and .ocdata files
  13. Note difference in apps between two versions
    cd /root
    ls /opt/owncloud-<old-version>/apps/owncloud/htdocs/apps > old-apps.txt
    ls /opt/owncloud-<new-version>/apps/owncloud/htdocs/apps > new-apps.txt
    diff old-apps.txt new-apps.txt
    The listed apps dont come by default and might have to be disabled in next step during upgrade
    All configuration / data related to these apps might be lost during upgrade.
    This is just for precaution. As such in most cases the app was found to show old data properly.
  14. Upgrade owncloud database
    cd /opt/owncloud-<new-version>/apps/owncloud/htdocs
    sudo -u daemon /opt/owncloud-<new-version>/php/bin/php occ upgrade
    #If there are warning to disable a few apps disable suggested apps using something similar to:
    sudo -u daemon /opt/owncloud-<new-version>/php/bin/php occ app:disable activity
    #After disabling old apps try upgrade again
    sudo -u daemon /opt/owncloud-<new-version>/php/bin/php occ upgrade
  15. Enable access to ports 80, 443 if disabled earlier.
  16. Start owncloud and check access.
    ./ctlscript.sh start
    Note that old server admin or user passwords would work. Password given during new stack installation will not work as it is overwritten when DB is restored.
  17. Go to owncloud market place and download latest version of disabled apps. Example URL: https://marketplace.owncloud.com/apps/activity
  18. Install app
    1. Copy the downloaded app installation file to /root/ of the owncloud server
    2. tar xzf <app-name>.tar.gz
    3. mv <app-name> /opt/owncloud-<new-version>/apps/owncloud/htdocs/apps
  19. Login into webUI as admin user:
    1. Go Settings -> Apps -> show disabled apps
    2. Activate the app whose files were copied to htdocs/apps folder in previous step
  20. Copy index.html from old version to new vesion
    cp /opt/owncloud-<old-version>/apache2/htdocs/index.html /opt/owncloud-<new-version>/apache2/htdocs/
  21. Assuming old setup took care of:
    1. Setup fail2ban using CentOS 7.x fail2ban including firewalld using CentOS 7.x Basic firewalld configuration
    2. Set correct time zone CentOS 7.x Change system timezone
    3. Configure system to store history date time using Storing date / time along with commands in history
    4. Proper logwatch and outgoing email configuration
  22. Show old crontab
    crontab -l
    and then comment all old crontab configuration using "crontab -e"
  23. Configure latest stack for lets-encrypt certificates using
    /opt/owncloud-10.5.0-1/bncert-tool --perform_public_ip_validation 0
  24. Use following values for bncert
    Domain list
    files.sbarjatiya.com
    Add www.files.sbarjatiya.com
    N
    Enable HTTP to HTTPS redirection
    Y
    Perform various changes
    Y
    Email address
    saurabh [at] sbarjatiya.com
    Agree to Lets encrypt subscriber agreement
    Y
  25. Update crontab using 'crontab -e and set first value between 3 and 6, second value between 10 and 50. Set last * to 0 so that certificate checks happen only weekly on Sundays.
  26. Validate https://<fqdn> is working as expected
  27. Assuming backup was configure using script such as /opt/take_database_backup.sh. Upgrade script with correct path and database parameters:
    cat /opt/owncloud-10.5.0-1/apps/owncloud/htdocs/config/config.php
    Note various values and update the backup script
  28. Execute /opt/take_database_backup.sh and test. If there is error shown for missing process privilege then use appropriate steps from https://docs.bitnami.com/installer/apps/owncloud/administration/change-reset-password/ as per MySQL version to reset root password.
  29. After root password is reset give process privilege using:
    show grants for bn_owncloud@'localhost';
    grant usage,process on *.* to 'bn_owncloud'@'localhost';
    flush privileges;
    \q
  30. Move all old folders to be deleted after a few days.
    mkdir /root/delete-later
    mv /root/new-temp-data /root/delete-later/
    mv /root/latest-bitnami-owncloud.sql /root/delete-later/
  31. Move all files of /opt/owncloud-<oldversion> except /opt/owncloud-<oldversion>/apps/owncloud/data to delete-later folder


Refer:


<yambe:breadcrumb self="Update lightsail owncloud instance in-place">CentOS 7.x Setup lightsail instances|Setup lightsail instances</yambe:breadcrumb>