ownCloud is a capable solution for storing your digital life on a private server. By default, data is saved on the same partition as the operating system, which may lead to a lack of free disk space. For instance, with high-resolution pictures and high-definition videos continuously being backed up, it is easy to run out of space. As your storage needs grow, it may become necessary to move ownCloud's
datadirectory. Whether you are adding more space or just looking to change the default storage location, this tutorial will guide you through relocating ownCloud’s
Before you begin using this guide, an ownCloud server needs to be installed and configured. You can set one up by following this guide. If our installation guide was used, then the
datadirectory is in ownCloud’s web root, which by default is located at
In this example, we are moving ownCloud’s
datadirectory to an attached additional storage volume that is mounted at
Regardless of the underlying storage being used, this guide can help you move the
datadirectory for ownCloud to a new location.
Step 1 — Moving the ownCloud Data DirectoryWhen ownCloud is in use and backend changes are being made, there is the possibility that data may become corrupt or damaged. To prevent that from happening, we will stop Apache with the
Some of the service management commands do not display an output. To verify that Apache is no longer running, use the
- sudo systemctl stop apache2
systemctlutility with the
The last line of the output should state that it’s stopped.
- sudo systemctl status apache2
[Output] . . . Stopped LSB: Apache2 web server.
Warning: It is highly recommended that you backup your data prior to making any changes.
Copy the contents of the
datadirectory to a new directory using the
rsynccommand. Using the
-aflag preserves the permissions and other directory properties, while the
-vflag provides verbose output so you can monitor the progress. In the example below, we back up our content into a new directory,
owncloud-data-bak, within our user's home directory.
- sudo rsync -av /var/www/owncloud/data/ ~/owncloud-data-bak/
Now that Apache is stopped, we will move the
datadirectory to the new location using the
- sudo mv /var/www/owncloud/data /mnt/owncloud/
datadirectory relocated, we will update ownCloud so that it’s aware of this change.
Step 2 — Pointing ownCloud to the New Data LocationownCloud stores its configurations in a single file, which we will edit with the new path to the
Open the file with the
- sudo nano /var/www/owncloud/config/config.php
datadirectoryvariable and update its value with the new location.
. . . 'datadirectory' => '/mnt/owncloud/data', . . .
datadirectory moved and the configuration file updated, we are ready to confirm that our files are accessible from the new storage location.
Step 3 — Starting ApacheNow, we can start Apache using the
systemctlcommand and regain access to ownCloud:
Finally, navigate to the ownCloud web interface:
- sudo systemctl start apache2
ownCloud is a web application and does not have a way to verify the integrity of its configuration. Therefore, access to the web interface means the operation was successful.
In this tutorial, we expanded the amount of disk space available to ownCloud. We accomplished this by moving its
datadirectory to an additional storage volume. Although we were using a block storage device, the instructions here should be applicable for relocating the
datadirectory regardless of the technology being used.