|
|
ff74a2f |
# Migration from owncloud
|
|
|
ff74a2f |
|
|
|
ff74a2f |
When migrating from an existing owncloud install it's possible to use the same database,
|
|
|
ff74a2f |
or to rename the database to reduce confusion.
|
|
|
ff74a2f |
|
|
|
ff74a2f |
Before carrying out the migration it is important to prevent anyone from changing things.
|
|
|
ff74a2f |
|
|
|
ff74a2f |
Of course it's advised to carry out a backup of the database and files before any migration.
|
|
|
8d3b856 |
|
|
|
8d3b856 |
### Prevent people using owncloud
|
|
|
8d3b856 |
sudo -u apache php /usr/share/owncloud/occ maintenance:mode --on
|
|
|
8d3b856 |
|
|
|
ff74a2f |
### Migration whilst keeping owncloud data intact
|
|
|
ff74a2f |
|
|
|
ff74a2f |
This is the safest option as it is nondestructive to owncloud, but it will require
|
|
|
ff74a2f |
double the data storage during the migration.
|
|
|
8d3b856 |
|
|
|
ff74a2f |
#### Copy data over from one location to the other
|
|
|
ff74a2f |
The data layout is identical, it's just the location that differs.
|
|
|
ff74a2f |
```
|
|
|
8d3b856 |
rsync -aPh /var/lib/owncloud/ /var/lib/nextcloud/
|
|
|
ff74a2f |
```
|
|
|
8d3b856 |
|
|
|
ff74a2f |
## Renaming the database
|
|
|
ff74a2f |
This is optional but might serve to confuse less, and prevents any changes to the owncloud
|
|
|
ff74a2f |
database in case there are issues requiring a fallback. Naturally use better credentials and
|
|
|
ff74a2f |
use the correct database names for your setup!
|
|
|
ff74a2f |
|
|
|
ff74a2f |
##### MySQL
|
|
|
ff74a2f |
```
|
|
|
8d3b856 |
mysql -e 'create database nextclouddb;'
|
|
|
8d3b856 |
mysql -e "grant all on nextclouddb.* to 'nextcloud_user'@'localhost' identified by 'nextcloud_pass';"
|
|
|
8d3b856 |
mysqldump -v ownclouddb | mysql -D nextclouddb
|
|
|
ff74a2f |
```
|
|
|
ff74a2f |
|
|
|
ff74a2f |
##### PostgreSQL
|
|
|
ff74a2f |
```
|
|
|
ff74a2f |
sudo -u postgres psql <
|
|
|
ff74a2f |
/* Create the user for nextcloud */
|
|
|
ff74a2f |
CREATE USER nextcloud_user WITH PASSWORD 'nextcloud_pass';
|
|
|
ff74a2f |
|
|
|
ff74a2f |
/* KILL ALL EXISTING CONNECTION FROM ORIGINAL DB (ownclouddb)*/
|
|
|
ff74a2f |
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
|
|
|
ff74a2f |
WHERE pg_stat_activity.datname = 'ownclouddb' AND pid <> pg_backend_pid();
|
|
|
8d3b856 |
|
|
|
ff74a2f |
/* CLONE DATABASE TO NEW ONE(nextclouddb) */
|
|
|
ff74a2f |
CREATE DATABASE nextclouddb WITH TEMPLATE ownclouddb OWNER nextcloud_user;
|
|
|
8d3b856 |
|
|
|
ff74a2f |
GRANT ALL PRIVILEGES ON DATABASE nextclouddb TO nextcloud_user;
|
|
|
ff74a2f |
|
|
|
ff74a2f |
/* The tables need to be transferred in owner as well */
|
|
|
ff74a2f |
\c nextclouddb;
|
|
|
ff74a2f |
REASSIGN OWNED BY owncloud_user TO nextcloud_user;
|
|
|
ff74a2f |
EOF
|
|
|
ff74a2f |
|
|
|
ff74a2f |
```
|
|
|
ff74a2f |
Don't forget to update pg_hba.conf to allow access to the new database as the new user!
|
|
|
ff74a2f |
|
|
|
ff74a2f |
```
|
|
|
ff74a2f |
host nextclouddb nextcloud_user ::1/128 password
|
|
|
ff74a2f |
host nextclouddb nextcloud_user 127.0.0.1/32 password
|
|
|
ff74a2f |
```
|
|
|
ff74a2f |
|
|
|
ff74a2f |
### Migration in place without preserving owncloud data
|
|
|
ff74a2f |
|
|
|
ff74a2f |
If there is not sufficient disk then data can be moved, this will break owncloud in the process
|
|
|
ff74a2f |
and there won't be a fallback option if things go wrong beyond restiring data/backups.
|
|
|
ff74a2f |
|
|
|
ff74a2f |
#### Copy data over from one location to the other
|
|
|
ff74a2f |
```
|
|
|
8d3b856 |
mv /var/lib/owncloud/* /var/lib/nextcloud/
|
|
|
ff74a2f |
```
|
|
|
ff74a2f |
|
|
|
ff74a2f |
#### Renaming the database
|
|
|
ff74a2f |
This is even more optional since the old database will be destroyed in the process, but it may serve
|
|
|
ff74a2f |
to lessen confusion later on for future maintenance. Again replace with the desired credentials and
|
|
|
ff74a2f |
database names for your environment.
|
|
|
8d3b856 |
|
|
|
ff74a2f |
Note that since the database sizes are small it's more reliable and safer for the data stores to follow
|
|
|
ff74a2f |
the steps to duplicate the database laid out above.
|
|
|
ff74a2f |
|
|
|
ff74a2f |
##### MySQL
|
|
|
ff74a2f |
```
|
|
|
ff74a2f |
mysql -e 'create database nextclouddb;'
|
|
|
8d3b856 |
mysql -e "grant all on nextclouddb.* to 'nextcloud_user'@'localhost' identified by 'nextcloud_pass';"
|
|
|
8d3b856 |
mysql ownclouddb -sNe 'show tables' | while read table; do mysql -sNe "rename table ownclouddb.$table to nextclouddb.$table;"; done
|
|
|
ff74a2f |
```
|
|
|
ff74a2f |
|
|
|
ff74a2f |
##### PostgreSQL
|
|
|
ff74a2f |
```
|
|
|
ff74a2f |
sudo -u postgres psql <
|
|
|
ff74a2f |
/* Create the user for nextcloud */
|
|
|
ff74a2f |
CREATE USER nextcloud_user WITH PASSWORD 'nextcloud_pass';
|
|
|
ff74a2f |
|
|
|
ff74a2f |
/* KILL ALL EXISTING CONNECTION FROM ORIGINAL DB (ownclouddb)*/
|
|
|
ff74a2f |
SELECT pg_terminate_backend(pg_stat_activity.pid) FROM pg_stat_activity
|
|
|
ff74a2f |
WHERE pg_stat_activity.datname = 'ownclouddb' AND pid <> pg_backend_pid();
|
|
|
ff74a2f |
|
|
|
ff74a2f |
/* ALTER DATABASE to rename it */
|
|
|
ff74a2f |
ALTER DATABASE ownclouddb RENAME TO nextclouddb;
|
|
|
ff74a2f |
ALTER DATABASE nextclouddb OWNER TO nextcloud_user;
|
|
|
ff74a2f |
|
|
|
ff74a2f |
GRANT ALL PRIVILEGES ON DATABASE nextclouddb TO nextcloud_user;
|
|
|
ff74a2f |
|
|
|
ff74a2f |
/* The tables need to be transferred in owner as well */
|
|
|
ff74a2f |
\c nextclouddb;
|
|
|
ff74a2f |
REASSIGN OWNED BY owncloud_user TO nextcloud_user;
|
|
|
ff74a2f |
EOF
|
|
|
ff74a2f |
```
|
|
|
8d3b856 |
|
|
|
ff74a2f |
Again remember to update pg_hba.conf so the new database and user can be used.
|
|
|
8d3b856 |
|
|
|
8d3b856 |
### Bring over the old configuration and update paths
|
|
|
ff74a2f |
The config can be copied as-is which will preserve most settings. This is a coarse rename of everything
|
|
|
ff74a2f |
from owncloud to nextcloud, but if the database isn't renamed then this too much. Verify the database
|
|
|
ff74a2f |
credentials and name in the config file are correct before moving on to the next step.
|
|
|
ff74a2f |
```
|
|
|
8d3b856 |
cp /etc/owncloud/config.php /etc/nextcloud/config.php
|
|
|
9639229 |
sed -i 's/owncloud/nextcloud/g' /etc/nextcloud/config.php
|
|
|
ff74a2f |
```
|
|
|
8d3b856 |
|
|
|
8d3b856 |
### Enable the nextcloud interface on httpd
|
|
|
ff74a2f |
If using httpd then enable the interface the same way as the README describes for a fresh install
|
|
|
ff74a2f |
```
|
|
|
8d3b856 |
ln -s /etc/httpd/conf.d/nextcloud-access.conf.avail /etc/httpd/conf.d/z-nextcloud-access.conf
|
|
|
ff74a2f |
```
|
|
|
8d3b856 |
|
|
|
8d3b856 |
### Carry out any migration required
|
|
|
ff74a2f |
A migration step for database schemas etc needs to be carried out to ensure everything is correct.
|
|
|
8d3b856 |
|
|
|
ff74a2f |
Although the WebUI will be prompting the standard "click here to update" it is best for this major
|
|
|
ff74a2f |
migration to carry it out at the command line.
|
|
|
ff74a2f |
```
|
|
|
ff74a2f |
sudo -u apache php /usr/share/nextcloud/occ upgrade
|
|
|
ff74a2f |
```
|
|
|
8d3b856 |
|
|
|
ff74a2f |
### Verify that everything looks right
|
|
|
ff74a2f |
It's best at this stage to enter as an admin and have the instance in single user mode only
|
|
|
ff74a2f |
```
|
|
|
ff74a2f |
sudo -u apache php /usr/share/nextcloud/occ maintenance:singleuser --on
|
|
|
8d3b856 |
sudo -u apache php /usr/share/nextcloud/occ maintenance:mode --off
|
|
|
ff74a2f |
```
|
|
|
ff74a2f |
__NOTE__ It is usual for things like webdav to be disabled during singleuser which may prevent seeing
|
|
|
ff74a2f |
files, however just use this to verify the admin screens. On testing apps needed to be disabled
|
|
|
ff74a2f |
and then enabled again for nextcloud to correctly pick them up.
|
|
|
8d3b856 |
|
|
|
ff74a2f |
### Enable allow people to use nextcloud
|
|
|
ff74a2f |
If things are looking good then open the floodgates to everyone else.
|
|
|
ff74a2f |
```
|
|
|
ff74a2f |
sudo -u apache php /usr/share/nextcloud/occ maintenance:singleuser --off
|
|
|
ff74a2f |
```
|
|
|
ff74a2f |
|
|
|
ff74a2f |
### Clean up the owncloud stuff
|
|
|
ff74a2f |
Finally clean up the old owncloud install, replace with the database and user for your own setup.
|
|
|
ff74a2f |
```
|
|
|
8d3b856 |
dnf remove -y owncloud\*
|
|
|
ff74a2f |
rm -rf /var/lib/owncloud /etc/owncloud /etc/httpd/conf.d/*owncloud*
|
|
|
ff74a2f |
# mysql
|
|
|
ff74a2f |
mysql -e "drop database ownclouddb; drop user owncloud_user@'localhost';"
|
|
|
ff74a2f |
# postgres
|
|
|
ff74a2f |
sudo -u postgres psql <
|
|
|
ff74a2f |
DROP DATABASE ownclouddb;
|
|
|
ff74a2f |
DROP USER owncloud_user;
|
|
|
ff74a2f |
EOF
|
|
|
ff74a2f |
```
|