ownCloud is a popular self-hosted replacement to cloud storage services such as Dropbox, Box.net, Google Drive and SkyDrive: ownCloud lets you retain ownership of the storage solution, and host it wherever you want, without being at the mercy of service providers’ usage policies and advertising-oriented data-mining.
Recently the ownCloud developers asked the Ubuntu repo maintainers to remove owncloud
server from their repos.
The reason for this is because older versions of ownCloud have vulnerabilities that don’t necessarily get patched: whilst the original ownCloud developers plug the holes in the versions they support, they cannot guarantee that these fixes propagate to the code managed by repos – and Ubuntu is widely used as a base for other distros. For example, Ubuntu 12.04 is still supported and forms the base for many derivatives, and has ownCloud 5 in its repos – but is not managed by ownCloud developers.
The ownCloud developers recommend using the openSUSE build service repository where they publish the latest version of ownCloud, and from which you can get the newest updates as they arrive.
If you’ve installed ownCloud from the Ubuntu 14.04 repositories, and you want to move over to the openSUSE build repo, here’s how you do it.
If moving up from ownCloud 5, consider migrating first to version 6 by way of a PPA or an older OC6 TAR… I’ll have to leave it up to you to find those for yourselves…
Backing up
These instructions are generic. You MUST test this in a VM before performing the steps on your live system.
Mantra: do not trust instructions/code snippets from the internet blindly if you are unsure of what exactly they will do.
Backup the database
Make a backup of the specific database used for ownCloud as per your database’s documentation.
For a simple MySQL dump do:
mysqldump -u $OC_USER "-p$OC_PASS" $OC_DATABASE > owncloud_db.sql.bkp
replacing, of course, the placeholders as appropriate.
Backing up the directories
If you installed ownCloud on Ubuntu 14.04 directory from the regular repos, you’ll find the following key anatomies:
- Main owncloud directory is in
/usr/share/owncloud
(call it$OCHOME
) - The
$OCHOME/config
directory is a symlink to/etc/owncloud
- the
$OCHOME/data
directory is a symlink to/var/lib/owncloud
- the
$OCHOME/apps
is where your ownCloud apps are installed
If this is not already the case, it wouldn’t hurt to change things to match this setup.
It would also be a very good idea to make a tar backup of these folders to ensure you have a copy should the migration go awry. You have been warned.
Moving apps, data and config folders
Move your ownCloud data directory to some location (for this example /var/lib/owncloud
but it could be anywhere) ; move your ownCloud config directory to /etc/config
It’s probably simply a good idea to not have your data
directory directly accessible under $OCHOME/data
It is also probably good to keep the original more variable apps
directory in /var/owncloud-apps
instead of lumped straight into the ownCloud home directory. Note that this directory also contains the “native” ownCloud apps, which get updated with each version of ownCloud – not just custom apps.
Once you have moved these folders out, $OCHOME
should no longer have data
and config
symlinks in it. As these are symlinks you can simply rm $OCHOME/{data,config}
If you get an error about these being actual directories that cannot be removed because they are empty…. you haven’t actually moved them. If they do not exist of course, that’s fine.
Uninstall and reinstall ownCloud
Uninstall ownCloud (do NOT purge!!)
apt remove owncloud
And add the new repo as per the instructions in http://software.opensuse.org/download/package?project=isv:ownCloud:community&package=owncloud
For Ubuntu 14.04 this is
wget http://download.opensuse.org/repositories/isv:ownCloud:community/xUbuntu_14.04/Release.key
apt-key add - < Release.key
echo 'deb http://download.opensuse.org/repositories/isv:/ownCloud:/community/xUbuntu_14.04/ /' >> /etc/apt/sources.list.d/owncloud.list
apt-get update && apt-get install owncloud
This makes the repository trusted (key download) then updates the sources and installs directly from the openSUSE repo.
NOTE – if you are following these instructions for Ubuntu 12.04 or any distro shipping a version older than ownCloud 6, you may want to consider upgrading to OC6 first before converting to the latest version 7 – make sure your test this scenario in a VM before doing anything drastic!
Restore files
The new ownCloud is installed at /var/www/owncloud
Remove the directory at $OCHOME
, then move /var/www/owncloud
to $OCHOME
so that it takes up the exact same place your old ownCloud directory was at.
Disable the automatically added owncloud site
a2disconf owncloud
And optionally delete /etc/apache2/conf-available/owncloud.conf
Now remove the default data
and config
directories, and link back in the other directories that you had cautiously moved out previously
rm -rf $OCHOME/{data,config}
#ln -s /var/owncloud-apps $OCHOME/apps
ln -s /etc/owncloud $OCHOME/config
(the apps line is commented out – because you must check what apps you are specifically restoring before squashing the default apps directory)
Finally edit $OCHOME/config/config.php
to be sure that it points to the correct locations. Notably check that the $OCHOME/apps
location exists, and that the data
folder is pointing to the right place (especially if you had to move it).
Update
Now go to your ownCloud main page in your web browser. You will be told that ownCloud needs to be updated to the newer version 7 – this will be done automatically.
Once done, ensure that everything is working as expected – add/remove files, navigate around ownCloud web, check that your apps are all working…
Reverting
If you do need to revert,
apt remove owncloud
rm /etc/apt/sources.list.d/owncloud.list
apt update && apt install owncloud
Finally proceed to restoring the files as above – or from backup TARs
Additionally, you will want to restore the old version of the database.
mysql -u $OC_USER "-p$OC_PASS" < owncloud_db.sql.bkp
Recent Comments