-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
ownCloud Database Migration
Michael Reid edited this page Sep 22, 2024
·
15 revisions
Starting with version 10.15.0, the ownCloud package will transition from SQLite to its original MySQL/MariaDB back-end. This update also includes optimized configurations to eliminate all warnings in the settings screen. However, the transition remains somewhat experimental and cannot yet be fully integrated into the upgrade wizard. As a result, some manual steps are required to complete the process. The good news is that this is a one-time task, and detailed step-by-step instructions for executing it via SSH are provided below:
- Install
redis
from the SynoCommunity repository - Enable SSH (if required) and connect to your DiskStation
- Setup some shortcuts as follows:
oc_usr=http
oc_php=/usr/local/bin/php74
oc_occ=/var/services/web/owncloud/occ
oc_sql=/usr/local/mariadb10/bin/mysql
oc_home=/var/services/web/owncloud
- Save your MySQL password (replacing the [...] with your value)
oc_rpwd=[your MySQL root password]
- Set a random password for the database user
oc_upwd=$(LC_ALL=C tr -dc '[:graph:]' </dev/urandom | head -c 30; echo)
- Enable maintenance mode
sudo -u $oc_usr $oc_php $oc_occ maintenance:mode --on
- Remove previous Apache redirect
sudo -u $oc_usr sed -i.bak '/^RewriteEngine On$/d; /^RewriteCond %{HTTPS} off$/d; /^RewriteRule ^(.*)$ https:\/\/%{HTTP_HOST}%{REQUEST_URI} \[L,R=301\]$/d' $oc_home/.htaccess
- Add HSTS to Apache config
sudo tee -a $oc_home/.htaccess > /dev/null <<EOF
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
</IfModule>
EOF
sudo chown $oc_usr $oc_home/.htaccess
- Create new MySQL database
$oc_sql -u root -p$oc_rpwd -e "create database owncloud; grant all privileges on owncloud.* to 'oc_admin'@'localhost' identified by '$oc_upwd';"
- Prepare environment for migration
sudo -u $oc_usr $oc_php $oc_occ config:system:set mysql.utf8mb4 --value=true
-
Open MariaDB 10 in DSM and enable TCP/IP connection
-
Disable maintenance mode
sudo -u $oc_usr $oc_php $oc_occ maintenance:mode --off
- Perform database conversion (can take several minutes)
sudo -u $oc_usr $oc_php $oc_occ db:convert-type --port=3307 --password=$oc_upwd --all-apps mysql oc_admin 127.0.0.1 owncloud
- Enable maintenance mode
sudo -u $oc_usr $oc_php $oc_occ maintenance:mode --on
- Configure database connection
sudo -u $oc_usr $oc_php $oc_occ config:system:set dbhost --value="localhost:/run/mysqld/mysqld10.sock"
-
Open MariaDB 10 in DSM and disable TCP/IP connection
-
Backup the PHP config file with attributes preserved
sudo cp -p /usr/syno/etc/packages/WebStation/PHPSettings.json /usr/syno/etc/packages/WebStation/PHPSettings.json.bak
- Modify the JSON file with jq
sudo jq '.["com-synocommunity-packages-owncloud"].extensions += ["pdo_mysql", "redis"]' /usr/syno/etc/packages/WebStation/PHPSettings.json > temp.json
- Move the modified file back to the original location
sudo mv temp.json /usr/syno/etc/packages/WebStation/PHPSettings.json
- Restore the original file's attributes (permissions, ownership, timestamps)
sudo cp --attributes-only /usr/syno/etc/packages/WebStation/PHPSettings.json.bak /usr/syno/etc/packages/WebStation/PHPSettings.json
- Restart Apache (if it fails to restart Apache may need to be started manually)
if jq -e 'to_entries | map(select((.key | startswith("'"com-synocommunity-packages-"'")) and .key != "'"com-synocommunity-packages-owncloud"'")) | length == 0' "/usr/syno/etc/packages/WebStation/PHPSettings.json" >/dev/null; then \
sudo /usr/syno/sbin/synoservice --restart pkgctl-Apache2.4 \
else echo "Failed to restart Apache" ;\
fi
- Configure memory caching
sudo -u $oc_usr $oc_php $oc_occ config:system:set memcache.local --value="\OC\Memcache\APCu"
- Configure file locking
sudo -u $oc_usr $oc_php $oc_occ config:system:set memcache.locking --value="\OC\Memcache\Redis"
sudo -u $oc_usr $oc_php $oc_occ config:system:set filelocking.enabled --value true
- Disable maintenance mode
sudo -u $oc_usr $oc_php $oc_occ maintenance:mode --off
- Configure background jobs
sudo -u $oc_usr $oc_php $oc_occ system:cron
- Home
-
Packages
- Adminer
- Aria2
- Beets
- BicBucStriim
- Borgmatic
- cloudflared
- Comskip
- Debian Chroot
- Deluge
- Duplicity
- dnscrypt-proxy
- FFmpeg
- FFsync
- Flexget
- Gstreamer
- Google Authenticator
- Home Assistant Core
- Jellyfin
- Kiwix
- [matrix] Synapse homeserver
- MinIO
- Mono
- Mosh
- Mosquitto
- Node-Exporter
- Radarr/Sonarr/Lidarr/Jackett
- SaltStack
- SickBeard Custom
- SynoCLI-Disk
- SynoCLI-Devel
- SynoCLI-File
- SynoCLI-Kernel
- SynoCLI-Misc.
- SynoCLI-Monitor
- SynoCLI-NET
- Synogear
- Concepts
- Development
- Resources