# Nextcloud, how to change data directory?

**URL:** https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235
**Category:** General Discussion
**Created:** [6 May 2017 17:10 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235 "2017-05-06T17:10:02Z")
**Posts on this page:** 16
**Page:** 1

<div class="post-metadata">

### Author: ![crik91](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/c/e274bd/32.png) [@crik91](https://dietpi.com/forum/u/crik91)
#### Post date: [6 May 2017 17:10 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/1 "2017-05-06T17:10:02Z")

</div>

Hi, I have Nextcloud on my Raspberry Pi 3. It runs fine but I need to change the data directory because I need to use a folder inside an external HDD.

I tried different ways with no succes, what can I do?

Thank you.

---

<div class="post-metadata">

### Author: ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)
#### Post date: [7 May 2017 09:28 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/2 "2017-05-07T09:28:24Z")

</div>

Hi,

We recommend changing DietPi user data locationt:  
[https://dietpi.com/forum/t/dietpi-software-user-data/400/1](https://dietpi.com/forum/t/dietpi-software-user-data/400/1)

---

<div class="post-metadata">

### Author: ![crik91](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/c/e274bd/32.png) [@crik91](https://dietpi.com/forum/u/crik91)
#### Post date: [8 May 2017 07:16 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/3 "2017-05-08T07:16:51Z")

</div>

I don’t want to change my DietPi user data folder, I prefer to let it as default. Is it possible to change the next cloud folder?

---

<div class="post-metadata">

### Author: ![Fourdee](https://dietpi.com/forum/user_avatar/dietpi.com/fourdee/32/11_2.png) [@Fourdee](https://dietpi.com/forum/u/Fourdee)
#### Post date: [8 May 2017 10:14 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/4 "2017-05-08T10:14:58Z")

</div>

> [@crik91](#):
>
> I don’t want to change my DietPi user data folder, I prefer to let it as default. Is it possible to change the next cloud folder?

> **[Is there a safe and reliable way to move data directory out of web root?](https://help.nextcloud.com/t/is-there-a-safe-and-reliable-way-to-move-data-directory-out-of-web-root/3642/2)**
>
> Once you move the data folder, you need to update the config.php file with the new datadirectory. For example, ‘datadirectory’ =\> ‘/private\_html/datastorage’, As far as I know this works fine with Nextcloud 10. I’m not sure about older versions.

config should be in:

```plaintext
/var/www/nextcloud/

```

---

<div class="post-metadata">

### Author: ![crik91](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/c/e274bd/32.png) [@crik91](https://dietpi.com/forum/u/crik91)
#### Post date: [8 May 2017 14:55 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/5 "2017-05-08T14:55:33Z")

</div>

Hi, yes. Tried all that things!  
I tried to change the path of the data directory. I moved all /mnt/dietpi\_userdata/nextcloud\_data files to /mnt/myexternaldrive/nextcloud, then done

```nohighlight
chown -R www-data:www-data /mnt/myexternaldrive/nextcloud

```

and changed settings in config.php and in oc\_storage in the database.

I still get _Data directory (/mnt/myexternaldrive/nextcloud) is invalid. Please check that the data directory contains a file “.ocdata” in its root._

I can’t find any nextcloud.conf. What may I do?

Thank you

---

<div class="post-metadata">

### Author: ![Morvar](https://dietpi.com/forum/letter_avatar_proxy/v4/letter/m/7cd45c/32.png) [@Morvar](https://dietpi.com/forum/u/Morvar)
#### Post date: [5 June 2017 17:47 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/6 "2017-06-05T17:47:55Z")

</div>

Bump.

I’d also like to see clear instruction for how to change the data directory to be within Nextcloud.

How does one for example edit oc\_storage and where it might even be located? Everything’s well hidden for a linux newbie like me.

---

<div class="post-metadata">

### Author: ![WarHawk](https://dietpi.com/forum/user_avatar/dietpi.com/warhawk/32/21_2.png) [@WarHawk](https://dietpi.com/forum/u/WarHawk)
#### Post date: [8 September 2017 08:48 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/7 "2017-09-08T08:48:52Z")

</div>

> [@Fourdee](#):
>
> Hi,
> 
> We recommend changing DietPi user data locationt:  
> [https://dietpi.com/forum/t/dietpi-software-user-data/400/1](https://dietpi.com/forum/t/dietpi-software-user-data/400/1)

I used this method…mounted an external 1TB harddrive, moved all user data, it’s now all on the external harddrive

THANKS!!!

---

<div class="post-metadata">

### Author: ![WarHawk](https://dietpi.com/forum/user_avatar/dietpi.com/warhawk/32/21_2.png) [@WarHawk](https://dietpi.com/forum/u/WarHawk)
#### Post date: [8 October 2017 23:38 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/8 "2017-10-08T23:38:24Z")

</div>

Just ran the web updater too

Worked like a champ!

---

<div class="post-metadata">

### Author: ![przemko](https://dietpi.com/forum/user_avatar/dietpi.com/przemko/32/2308_2.png) [@przemko](https://dietpi.com/forum/u/przemko)
#### Post date: [22 March 2020 13:05 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/9 "2020-03-22T13:05:43Z")

</div>

> [@](#):
>
> Hi,
> 
> We recommend changing DietPi user data locationt:  
> [https://dietpi.com/forum/t/dietpi-software-user-data/400/1](https://dietpi.com/forum/t/dietpi-software-user-data/400/1)

Hi, I use that method to move my data but when I open nextcloud and users tab I see that my data is in `/mnt/dietpi_userdata/nextcloud_data/`. I have also my data in `/mnt/Toshiba/dietpi_userdata/nextcloud_data/`

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [22 March 2020 13:08 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/10 "2020-03-22T13:08:07Z")

</div>

pls can you past output of

```nohighlight
ls -la /mnt/

```

---

<div class="post-metadata">

### Author: ![przemko](https://dietpi.com/forum/user_avatar/dietpi.com/przemko/32/2308_2.png) [@przemko](https://dietpi.com/forum/u/przemko)
#### Post date: [22 March 2020 13:23 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/11 "2020-03-22T13:23:55Z")

</div>

That is:

```nohighlight
drwxr-xr-x 8 root root 4096 mar 21 08:11 .
drwxr-xr-x 21 root root 4096 mar 22 09:33 ..
lrwxrwxrwx 1 root root 28 mar 20 21:45 dietpi_userdata -> /mnt/Toshiba/dietpi_userdata
drwxr-xr-x 2 root root 4096 sty 7 23:35 ftp_client
drwxr-xr-x 2 root root 0 lut 14 2019 Maly
drwxrwxrwx 1 root root 8192 mar 20 19:38 My_Passport
drwxr-xr-x 2 root root 4096 sty 7 23:35 nfs_client
drwxr-xr-x 2 root root 4096 sty 7 23:35 samba
drwxr-xr-x 4 www-data www-data 4096 mar 20 21:45 Toshiba

```

---

<div class="post-metadata">

### Author: ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)
#### Post date: [22 March 2020 13:25 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/12 "2020-03-22T13:25:39Z")

</div>

That is all correct. When changing the userdata location, a symlink is left behind, so the old path stays valid while the actual data is on the new drive.

---

<div class="post-metadata">

### Author: ![przemko](https://dietpi.com/forum/user_avatar/dietpi.com/przemko/32/2308_2.png) [@przemko](https://dietpi.com/forum/u/przemko)
#### Post date: [22 March 2020 13:48 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/13 "2020-03-22T13:48:24Z")

</div>

But I see that path i nextcloud web app and all my data sync with that location. So I have to delete my data from

```nohighlight
/mnt/dietpi_userdata/nextcloud_data/admin

```

?

---

<div class="post-metadata">

### Author: ![Joulinar](https://dietpi.com/forum/user_avatar/dietpi.com/joulinar/32/57_2.png) [@Joulinar](https://dietpi.com/forum/u/Joulinar)
#### Post date: [22 March 2020 13:52 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/14 "2020-03-22T13:52:02Z")

</div>

Yes thats all correct. As you can see there is a symlinc from old to new location

```nohighlight
dietpi_userdata -> /mnt/Toshiba/dietpi_userdata

```

---

<div class="post-metadata">

### Author: ![przemko](https://dietpi.com/forum/user_avatar/dietpi.com/przemko/32/2308_2.png) [@przemko](https://dietpi.com/forum/u/przemko)
#### Post date: [22 March 2020 14:10 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/15 "2020-03-22T14:10:33Z")

</div>

OK, thanks. Now I install fail2ban on my Rpi4 and cannot open Nextcloud, Emby and ssh 😕 Can You help with that? I will create another topic for that.

---

<div class="post-metadata">

### Author: ![MichaIng](https://dietpi.com/forum/user_avatar/dietpi.com/michaing/32/7_2.png) [@MichaIng](https://dietpi.com/forum/u/MichaIng)
#### Post date: [23 March 2020 17:16 UTC](https://dietpi.com/forum/t/nextcloud-how-to-change-data-directory/1235/16 "2020-03-23T17:16:36Z")

</div>

Hmm, fail2ban should not be related to web access, especially not Nextcloud. By default it controls SSH access failures only and block access (completely) for a specific client when SSH access failed for, AFAIK 6 times, although might be 3 attempts only since each produces two log entries, AFAIK. Should be released after 600 seconds/10 minutes by default.

Were you able to access via SSH and web before installing fail2ban?
