CentOS 7.x Update lightsail owncloud instance in-place
From Notes_Wiki
<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
- ssh to VM
- Upgrade packages:
- yum -y install vim epel-release wget
- yum -y install perl-Data-Dumper byobu
- Download latest bitnami owncloud installer from https://bitnami.com/stack/owncloud/installer
- Stop old owncloud instance
- cd /opt/owncloud-<old-version>
- ./ctlscript.sh stop
- disable access to ports 80, 443 temporarily via firewall if possible.
- Install latest stack
- cd /root/
- chmod +x bitnami*
- ./bitnami-*
- Validate swap is available or else add it using CentOS 7.x adding swap space using file
- 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
- Stop latest installed stack using
- cd /opt/owncloud-<new-version>
- ./ctlscript.sh stop
- 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
- 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
- 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
- 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.
- 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
- Enable access to ports 80, 443 if disabled earlier.
- 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.
- Go to owncloud market place and download latest version of disabled apps. Example URL: https://marketplace.owncloud.com/apps/activity
- Install app
- Copy the downloaded app installation file to /root/ of the owncloud server
- tar xzf <app-name>.tar.gz
- mv <app-name> /opt/owncloud-<new-version>/apps/owncloud/htdocs/apps
- Login into webUI as admin user:
- Go Settings -> Apps -> show disabled apps
- Activate the app whose files were copied to htdocs/apps folder in previous step
- Copy index.html from old version to new vesion
- cp /opt/owncloud-<old-version>/apache2/htdocs/index.html /opt/owncloud-<new-version>/apache2/htdocs/
- Assuming old setup took care of:
- Setup fail2ban using CentOS 7.x fail2ban including firewalld using CentOS 7.x Basic firewalld configuration
- Set correct time zone CentOS 7.x Change system timezone
- Configure system to store history date time using Storing date / time along with commands in history
- Proper logwatch and outgoing email configuration
- Show old crontab
- crontab -l
- and then comment all old crontab configuration using "crontab -e"
- Configure latest stack for lets-encrypt certificates using
- /opt/owncloud-10.5.0-1/bncert-tool --perform_public_ip_validation 0
- 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
- 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.
- Validate https://<fqdn> is working as expected
- 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
- 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.
- 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
- 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/
- 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>