Rocky 9.x Owncloud upgrade by migrating to a new VM with updated version
From Notes_Wiki
Home > Rocky Linux or CentOS > Rocky Linux 9.x > File Sharing > Owncloud > Upgrade and Migrate
To upgrade owncloud along with migrating to a new VM (Typically cloud or at least public) use:
- Stop web server on old server. For example
- /opt/owncloud-<ver>/ctlscript.sh stop apache
- Take one full backup of files and DB on backup server
- As such in below steps we are only doing migration to a new VM. We are not disturbing old VM. So backup is optional.
- Create a new VM for the migrated data along with upgraded owncloud version.
- The below steps were tested on Rocky Linux 9.x while migrating from owncloud 10.5 or 10.7 to 10.11
- Add approriate disk for required storage
- Login into VM via root SSH
- Set appropriate hostname
- hostnamectl set-hostname files-new.example.com
- Validate the storage disk, if required is visible at OS level. Create a physical partition for LVM purposes
fdisk -l fdisk /dev/sd<n> n p 1 <enter> <enter> t 8e w
- Install lvm2 package, if not present and create required filesystem. Mount the created filesystem on desired path via:
dnf -y install lvm2 pvcreate /dev/sd<n>1 vgcreate vgfiles /dev/sd<n>1 lvcreate -n lvfiles -l '100%VG' vgfiles mkfs.ext4 /dev/mapper/vgfiles-lvfiles blkid #Edit /etc/fstab and mount /dev/mapper/vgfiles-lvfiles on /opt mount -a df -h
- Mount the Logical on desired final location of DataDirectory. If DataDirectory will not be in /opt but would be /mnt/files then mount the partition appropriately.
- Note Rocky 9.x Owncloud Manually moving DataDirectory. We can change DataDirectory during upgrade using this reference, if required.
- Install owncloud via:
- dnf -y install epel-release
- dnf -y install screen
- screen -d -RR byobu
- See CentOS 7.x screen
- Other new server setup related tasks:
- Increase swap to 4GB
- CentOS 7.x adding swap space using file
- Command line history retention
- Storing date / time along with commands in history
- Timezone
- CentOS 8.x Change system timezone
- Fail2ban
- CentOS 7.x fail2ban
- Install all OS level updates
- dnf update -y
- Disable selinux using:
sed -i --follow-symlinks 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux setenforce 0 getenforce
- Allow ports 80 and 443 via firewalld using:
firewall-cmd --zone=public --add-port=80/tcp --permanent firewall-cmd --zone=public --add-port=443/tcp --permanent firewall-cmd --reload firewall-cmd --list-all
- (Optionally) Edit /etc/hosts on the new VM and add entry mapping VM interface IP (ip addr show) to desired FQDN
- On admin station add /etc/hosts entry to point to this new server via FQDN. This would help in testing the new setup before changing DNS entry to point to new server.
- Setup php 7.4 via Remi and install httpd, php, mariadb etc. via:
dnf install -y http://rpms.remirepo.net/enterprise/remi-release-9.rpm dnf install -y dnf-utils dnf module reset php -y dnf module enable php:remi-7.4 -y dnf install -y php php-curl php-gd php-intl php-json php-ldap php-mbstring php-mysqlnd php-xml php-process php-zip php-opcache mariadb-server httpd wget unzip tar
- Download OwnCloud server sources via
cd /root wget https://download.owncloud.com/server/stable/owncloud-complete-latest.zip #version 10.11 at time of writing unzip -q owncloud-complete-latest.zip mv owncloud /var/www/html chown -R apache:apache /var/www/html/owncloud
- Update default php resources values using Rocky 9.x Increase default PHP resources
- Without the increase in these limits we may see many blacklist errors on owncloud desktop client during sync
- Refer: https://central.owncloud.org/t/item-is-on-blacklist-how-to-verify-see-them-and-remove/23750/6 and https://github.com/owncloud/client/issues/2247
- Increase concurrency settings via Rocky 9.x Configure apache web server for concurrency to improve performance
- Start and enable services
- systemctl start mariadb
- systemctl enable mariadb
- systemctl start httpd
- systemctl enable httpd
- Read values of
- dbname
- dbtableprefix
- dbuser
- dbpassword
- from old installation via
- cd /opt/owncloud-<version>/apps/owncloud/htdocs
- unalias -a
- vi config/config.php
-
- In above commands replace '/opt/owncloud-<ver>/apps/owncloud/htdocs/' with old server Web server DocumentRoot appropriately
- Configure database on new machine. We can optionally configure DB with exact same vlaues of db-name, db-username and db-password as on old machine to avoid changing these parameters elsewhere.
- mysql_secure_installation
- mysql -u root -p #Even vanilla "mysql" seems to work!!
- CREATE DATABASE <dbname>;
- GRANT ALL ON <dbname>.* TO '<dbuser>'@'localhost' IDENTIFIED BY '<dbpassword>';
- FLUSH PRIVILEGES;
- exit
- Restore latest DB backup taken on old server to new server
- Add /etc/hosts entry on old server pointing to new server
- Allow keys from old server to new as authorized
- ssh-copy-id from old to new or copy manually
- Run below if DB backup is not recent (After entering maintenance mode)
- ls -lt /opt
- /opt/take-database-backup.sh
- Or take backup as explained at CentOS 8.x mariadb taking backup of large production databases
- Install rysnc and bzip2 on both old and new server, if not already present:
- dnf -y install rsync bzip2
- Rsync Database dump from old server to new server
- rsync -vtrp /opt/owncloud.sql.bz2 root@new-files.example.com:/opt/
- Restore DB backup copied via rsync on new server using:
- cd /opt
- bunzip2 owncloud.sql.bz2
- mysql
- use <db-name>
- source /opt/owncloud.sql
- IN PARALLEL copy files to same path in new machine
- #On new VM
- mkdir /opt/owncloud-10.0.10-4/apps/owncloud/data -p
- #on old server
- cd /opt/owncloud-<ver>/apps/owncloud/data
- rsync -a ./ root@new-files.sunilsanjay.com:$PWD/
- Assuming not trying to change DataDirectory via Rocky 9.x Owncloud Manually moving DataDirectory during migration.
- If you are trying to Change DataDirectory then rsync destination should be the new DataDirectory. Also need to follow DB and config related changes as explained at Rocky 9.x Owncloud Manually moving DataDirectory
- Create /var/www/html/owncloud/config/config.php by copying old config file using:
- #From old server copy config.php to new server /root/old-config.php
- cd /opt/owncloud-<ver>/apps/owncloud/htdocs/config
- rsync -vtrp config.php root@new-files.example.com:/root/old-config.php
- #On new server go to /var/www/html/owncloud/config
- cd /var/www/html/owncloud/config
- cp /root/old-config.php ./config.php
- chown apache:apache config.php
- In above commands replace '/opt/owncloud-<ver>/apps/owncloud/htdocs/' with old server Web server DocumentRoot appropriately
- Edit /var/www/html/owncloud/config/config.php and update at least following parameters:
- datadirectory - /opt/owncloud-10.0.10-4/apps/owncloud/data
- Set this as per new Data Directory desired. Could be /mnt/files
- As explained earlier if data directory is changing need to follow Rocky 9.x Owncloud Manually moving DataDirectory
- dbhost
- localhost:/var/lib/mysql/mysql.sock
- apps_paths
- Use paths as /var/www/html/owncloud/apps and /var/www/html/owncloud/apps-external
- openssl - Comment using /* */ php style multiline comments
- On new server create apps-external folder as specified in apps_path config parameter via:
- mkdir -p /var/www/html/owncloud/apps-external
- chmod 777 /var/www/html/owncloud/apps-external
- On new server, Only after DB restore (eg 'source owncloud.sql) finishes, try occ:upgrade and solve issues, if any one by one
- cd /var/www/html/owncloud
- sudo -u apache php -f occ upgrade
- For potential issues during upgrade also see old article at CentOS 7.x Upgrade owncloud to newer version or updated stack
- Login into new server http://<IP>/owncloud as admin and validate it is working.
- If you have added /etc/hosts entry in admin station the we can open the URL via FQDN also
- Change DNS entry and make it point to new server, if the migration and upgrade was successful
- Generate lets encrypt certificate on new server using (Owncloud can be in maintenance mode while doing this)
- Restart apache
- systemctl restart httpd
- Install required packages for SSL and Lets Encrypt
- dnf -y install mod_ssl
- dnf -y install certbot python3-certbot-apache
- Edit /etc/httpd/conf/httpd.conf with following values to create appropriate VirtualHost for certificate generation
NameVirtualHost *:80 <VirtualHost *:80> ServerAdmin saurabh@sbarjatiya.com DocumentRoot /var/www/html ServerName files.gbb.co.in ErrorLog logs/files.example.comerror_log CustomLog logs/files.example.com-access_log combined </VirtualHost>
- Request certificate via lets encrypt using:
- certbot --apache
- Use values such as:
- saurabh@sbarjatiya.com
- Terms of service
- Y
- share email id
- Y
- Select domains
- 1
- Edit /etc/httpd/conf.d/ssl.conf and replace SSLCertificateFile and SSLCertificateKeyFile with:
- SSLCertificateFile /etc/letsencrypt/live/files.example.com/fullchain.pem
- SSLCertificateKeyFile /etc/letsencrypt/live/files.example.com/privkey.pem
- Restart apache
- systemctl restart httpd
- Test the HTTPs url https://files.example.com/owncloud/
- Stop httpd till maintenance is completed (Perhaps File copying is still going on via rsync in parallel)
- systemctl stop httpd
- Configure SSL certificate auto renewal via
- Run below shell command
- certbot renew --dry-run
- In 'crontab -e' use below after randominzing minute(10) and hour (11) from below line:
- 10 11 * * 0 /usr/sbin/certbot-auto renew
- Validate crontab config
- crontab -l
- Run below shell command
- Restart apache
- Create redirect from / to /owncloud URL via
- cd /var/www/html
- wget www.sbarjatiya.com
- vi index.html
- -- Change URL=owncloud in HTTP META REFRESH LINE
- -- Optionally delete <title>
- Only After rsync of file finishes proceed further by, on new server set correct ownership of files:
- chown -R apache:apache /opt/owncloud-<ver>/apps/owncloud/data
- chown apache:apache /var/www/html/owncloud/config/*
- systemctl start httpd
- cd /var/www/html/owncloud
- sudo -u apache php -f occ maintenance:mode --off
- In above commands replace '/opt/owncloud-<ver>/apps/owncloud/data/' with new server desired / configured DataDirectory path appropriately
- Configure owncloud cron jobs via 'crontab -e' using:
- */5 * * * * /usr/bin/sudo -u apache /usr/bin/php -f /var/www/html/owncloud/occ system:cron
- Install sshpass and configure backup script via
- Install package
- dnf -y install sshpass
- Create /opt/take_database_backup.sh with
#/bin/bash sshpass -p <db-password> mysqldump -u <db-username> -p <database-name> | bzip2 > /opt/owncloud.sql.bz2 exit 0
- Set execute permissions\
- chmod +x /opt/take_database_backup.sh
- Configure appropriate backups for this server. During backup above created script can be run to take owncloud DB-backup in /opt
- For large deployments change backup script to use CentOS 8.x mariadb taking backup of large production databases
- Test and validate backups
- Install package
- Logwatch configuration via:
- dnf -y install postfix logwatch
- Configure postfix by editing '/etc/postfix/main.cf'
- See step "Set at least following in /etc/postfix/main.cf for mail system to work properly: " from CentOS 8.x postfix send email through relay or smarthost with smtp authentication
- Restart postfix
- systemctl restart postfix
- systemctl enable postfix
- edit /etc/aliases for root email to go to appropriate ID
- Update aliases DB
- newaliases
- Test whether logwatch emails are coming by executing:
- /etc/cron.daily/0logwatch
- This assumes direct outgoing email from the current server (Eg linode)
There is older version of this article at: CentOS 7.x Upgrade owncloud to newer version or updated stack
Home > Rocky Linux or CentOS > Rocky Linux 9.x > File Sharing > Owncloud > Upgrade and Migrate