OwnCloud to NextCloud

Fonte: ARDITI - WIKI
Saltar para a navegação Saltar para a pesquisa

Migration from Owncloud To Nextcloud

Procedure

#Set owncloud in maintenance mode
cd /var/www/owncloud
sudo -u www-data php occ maintenance:mode --on

#clone the database
 mysqldump --login-path=local --add-drop-database --databases owncloud > owncloud_dump.sql
cp owncloud_dump.sql nextcloud_initdb.sql
vim nextcloud_initdb.sql
# IMPORTANT: change the create database from owncloud to nextcloud
# AND ADD: GRANT ALL PRIVILEGES ON nextcloud.* TO 'nc_admin'@'localhost' IDENTIFIED BY ‘35eb5bc2e47448bfabad77dfef3dbd';
# After the database creation line

mysql --login-path=local < nextcloud_initdb.sql

cd /var/www
wget https://download.nextcloud.com/server/releases/nextcloud-12.0.4.zip
unzip nextcloud-12.0.4.zip
# copy the config 
cd /var/www/nextcloud
cp ../owncloud/config/config.php config/
#CHANGE THE VALUES in config
chown www-data: -R .
sudo -u www-data php occ upgrade
# create vhost document root
vim /etc/apache2/sites-enabled/owncloud-vhost.conf

# add opcache 
vim /etc/php/7.0/apache2/php.ini

opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1

#Change the cronjob 
crontab -u www-data -e

Run the fixNextCloudPermissions.sh script just to be sure
https://docs.nextcloud.com/server/9.0/admin_manual/installation/installation_wizard.html#setting-strong-directory-permissions

Fix checksums:

UPDATE oc_filecache SET checksum = '' WHERE COALESCE (checksum, '') <> '';
Cd /var/www/nextcloud
sudo -u www-data php occ maintenance:mode --on # this is need for the next command to work
sudo -u www-data php occ files:scan --all

# install certbot and get a new letsencrypt certificate

sudo -u www-data php occ maintenance:mode --off

Virtual Host file

<syntaxhighlight lang="apache"> <VirtualHost *:80>

 ServerName nextcloud.arditi.pt
 ServerAlias cloud.arditi.pt owncloud.arditi.pt
 ErrorLog ${APACHE_LOG_DIR}/error.log
 DocumentRoot /var/www/nextcloud/

</VirtualHost>

</syntaxhighlight>

script to fix nextcloud permissions

<syntaxhighlight lang="bash">

  1. !/bin/bash

ncpath='/var/www/nextcloud' htuser='www-data' htgroup='www-data' rootuser='root'

printf "Creating possible missing Directories\n" mkdir -p $ncpath/data mkdir -p $ncpath/assets mkdir -p $ncpath/updater

printf "chmod Files and Directories\n" find ${ncpath}/ -type f -print0 | xargs -0 chmod 0640 find ${ncpath}/ -type d -print0 | xargs -0 chmod 0750

printf "chown Directories\n" chown -R ${rootuser}:${htgroup} ${ncpath} chown -R ${htuser}:${htgroup} ${ncpath}/apps/ chown -R ${htuser}:${htgroup} ${ncpath}/assets/ chown -R ${htuser}:${htgroup} ${ncpath}/config/ chown -R ${htuser}:${htgroup} ${ncpath}/data/ chown -R ${htuser}:${htgroup} ${ncpath}/themes/ chown -R ${htuser}:${htgroup} ${ncpath}/updater/

chmod +x ${ncpath}/occ

printf "chmod/chown .htaccess\n" if [ -f ${ncpath}/.htaccess ]

then
 chmod 0644 ${ncpath}/.htaccess
 chown ${rootuser}:${htgroup} ${ncpath}/.htaccess

fi if [ -f ${ncpath}/data/.htaccess ]

then
 chmod 0644 ${ncpath}/data/.htaccess
 chown ${rootuser}:${htgroup} ${ncpath}/data/.htaccess

fi </syntaxhighlight>