Friday, September 28, 2018

How to manually move the owncloud data directory to another location


These are the steps taken to manually move a data directory from it’s current location to a new location in ownCloud. Some of the reasons you’d like to move your data directory are:
  • You need to migrate your data to bigger space if your current drive is running out of space
  • You may have issues with your Apache loading .htaccess files needed to secure your data directory from internet access. Instead of enabling .htaccess processing, you could just move the data directory to a new location

Prerequisites
OwnCloud already installed and running on Apache web server, Centos 7
In this tutorial, I assume the following:
  • Your current data directory is /var/www/html/owncloud/data
  • Your new directory is /mnt/new/owncloud

Move the data directory
First of all, copy a backup of your data directory. It’s always important to have a backup.
1. Stop apache web server

[root@centos7box]# systemctl stop httpd

2. Copy/Move the files from current data directory to new data directory. You can use cp, rsync or mv commands to achieve this. Here, I use rsync command with -a option to make sure file attributes are maintained while copying to the new location

[root@centos7box]#rsync -avz /var/www/html/owncloud/data /mnt/new/owncloud

3. Create a symbolic link from the new directory to the old one. For me, this was the step I was missing. Without this, the new owncloud directory would have permission issues. Files would be displayed on the web browser accounts but you can’t open them or download. You also wouldn't be able to upload new files.

[root@centos7box]# ln -s /mnt/new/owncloud /var/www/html/owncloud/data


4. Check if your directory permissions are okay. You should have your directory permissions matching those of the old data directory location. Here is a simple table with the old and new permissions, owners and group

OLD
/var/ root:root 755
/www/ root:root 755
/html/ root:apache 755
/owncloud/ root:apache 755
/data/ apache:apache 770

NEW
/mnt/ root:root 755
/new/ root:apache 755
/owncloud/ apache:apache 770

5. Start apache
[root@centos7box]# systemctl start httpd

Refernces


No comments:

Post a Comment