Manually Move the Data Directory
- Stop the Web Server
- Enable Maintenance Mode
- Sync your Data Directory
- Adjust ownCloud’s configuration
- Fix the config.php Settings
- Disable Maintenance Mode
- Start the Web Server
Use this instructions if you intend to move your ownCloud’s data directory from it’s current location to another without using a symbolic link.
Though using symbolic links to relocate the data directory can be beneficial, it can be necessary to hard relocate it. If a hard relocation is required, not only the physical location but also the database has to be updated.
This guide assumes that:
The current folder is:
The new folder is:
You’re using Apache as your webserver
ownCloud’s database name is
Please change the paths above to reflect your environment.
The following steps are necessary to move the data directory.
Stop the web server
Enable maintenance mode
Sync your Data directory
Adjust ownCloud’s configuration
Disable maintenance mode
Start the web server
Look at each section below for a detailed description.
Stopping the web server makes sure there are no active connections to your server.
sudo service apache2 stop
It is necessary to enable maintenance mode to avoid running cron jobs. To enable maintenance mode, run the following command.
sudo -u www-data ./occ maintenance:mode --on
sudo rsync -avz /var/www/owncloud/data /mnt/owncloud
Make sure that
.htaccess were synced to the new directory.
ls -a | grep -i "^\.[A-Z]"
Run the SQL below:
You next need to update the
home column in the
This column contains the absolute path for user folders, e.g.,
If a user does not have the path already set, you have to identify the users
id and set the path with the following command, user by user.
This example assumes the user name is
my_user and their id is
Run the SQL below:
UPDATE oc_accounts SET home='/mnt/owncloud/data/my_user/files'
For all users who already have a path like
/var/www/owncloud/data/ in your database, you can use the
SET home = REPLACE(
For more information follow the complete MySQL REPLACE command syntax.
|Please don’t copy and paste this example verbatim — nor any of the others. They are examples only.
The next area to check is the
The logrotate process may have hard-coded a non-standard (or old) value for the data path.
To check it, run the SQL below and see if any results are returned:
SELECT * FROM oc_jobs
WHERE class = 'OC\Log\Rotate';
If results are returned, run the SQL below to update them, changing the id value as appropriate.
SET argument = REPLACE(
WHERE id = <id of the incorrect record>;
The old data path will be written with
Therefore you must add one, additional, backslash, like this:
To fix the config.php settings:
sudo -u www-data ./occ config:system:set --value /mnt/owncloud/data datadirectory
To disable maintenance mode of your instance run the following command:
sudo -u www-data ./occ maintenance:mode --off