Nextcloud Pi, wanting to add second HDD for backup

Hi All

I have what I think must be quite a common issue. I setup my Nextcloud instance using Nextcloud Pi OS image for the raspberry Pi back in 2019. It has been running mostly without hiccup since, but only on a single USB drive. Which is a glaring red siren flashing beacon of an issue when it comes to backup strategy and I now need to do something about it. (I previously posed about the in 2021 and then life gets in the way so I really, really need to sort it now)

Im currently up to date on Nextcouldpi version V1.51.0 running nextcloud (I think my version of PHP is stopping me going further but that’s for another day).

I have a second USB drive to use as a backup and followed this guide (How to periodically backup to a second USB drive with NextCloudPi) to format it by taking the old drive out and putting the new one in to get next cloud to format it properly for me. I gave it the mybackup label using nc-format-usb tool so that the new drive is /media/mybackup.

However as when I originally setup everything I don’t believe I added a label to the original drive and just relied on Automount. So this is what is seen for my existing drive.

NCP System info lists my datadir as /media/USBdrive/ncdata
NC settings page shows it as /media/myCloudDrive

When I plug in my new drive that I want to use as a backup it all gets confused as ncp seems to forget my original drive and it can’t find my datadir. When I unplug the backup drive and restart with only my original drive, all is back and working, so I think it is a label issue with my original drive.

Previously I have been pointed to using UUID and fstab but that seems more like for moving the datadir to a new disk.

I have also seen mention of manually editing the config.php file to add the label of the datadir so it is set on the right drive which would be /media/myCloudDrive (I think from what is shown in NC settings) and not relying on automount and there only being 1 drive in the system. But I don’t know how to go about it.

However, I will freely admit (much to my annoyance) I am not greatly linux literate, but I can follow instructions and learn from them. However, whilst I have read posts on this forum and generally, online there are bits of information that are relevant to what I need to do, but not a guide or complete post that does it all and the last thing I want to do is in attempting to secure my data with a backup strategy, screw it up as Im getting a command wrong.

I was wondering if it is as simple as using nc-datadir in the NCP panel and just putting /media/myCloudDrive in there rather than /media/USBdrive/ncdata? but I don’t want to move the directory just set it where it is on that drive.

So I humbly ask for the collective help and guidance this forum has on tap, with an idiots guide…
Please. Thanks in advance.

I hope that it is as simple as editing the config.php in a terminal (I can plug in keyboard etc and work directly on the Pi rather than SSH) but its how I go about it on a Pi install based on the SD image rather than snappy or docker etc.

Equally, if there is already an exact guide for this, link it and call me an even bigger idiot but I couldn’t find what I needed, maybe I’m not asking the right question though.


Fstab is used for mounting disks. Try using it to mount the disk to your preferred location. Sounds like you never followed through on it.

Search the forum or internet for many examples and guides.

Hi Just,

I had looked at the instructions given at Mounting an external drive using UUID and fstab | Linux admin junior

But that talks about making a data dir for nextcloud and using UUID rather than a label, which is where I got confused. Fell at the first hurdle as it were. I already have the datadir on the disk. I just need to set the label of the drive I believe so that it is fixed, rather than simply relying on it being the only HDD there. So when I plug the other drive in and it auto mounts, nextcloud doesn’t look at that expecting to find the datadir there.

The guide here How to periodically backup to a second USB drive with NextCloudPi

Taht Says to:
Important: make sure you use the drive label in nc-datadir and other configuration options. Use names such as /media/myCloudDrive, instead of /media/USBdrive, or otherwise the system will not be able to guess which drive holds the data and which one holds the backups.

But it doesn’t say what to do with the original drive. I don’t know how to set the label for the original one to be I assume /media/myCloudDrive/ncdata rather than /media/USBdrive/ncdata. Do I just input it in the ncp panel under nc-datadir? Or would that make it think I was moving the data dir and fail as its already there. That what lead me to another article I cant find right now which raised editing the config.php to just put the actual datadir location in there rather than /media/USBdrive/ncdata.
But I guess I’m not really sure where to start.
I will have another trawl through the forum.

Use fstab to mount your disk to /wherever/you/want

Has nothing to do with the data directory so ignore that and use fstab to mount a disk to a location. Once you understand the process and can access your disk from a location it’ll make more sense.

I will do my research into fstab so I understand it more… And image the SD card before I mess with anything. Changing the mount point won’t erase any data? I assume once I have done the fstab magic to set a label will I have to tell next cloud where the datadir etc is or will the datadir essentially be in the same place it’s just the mount point I’m setting.

Stop messing with Nextcloud; don’t get ahead of yourself.
Only focus on fstab to mount a disk.
Try with a thumb drive on a different computer or laptop. It should take you editing the fstab file to achieve.

Let us know once you’ve done that.

df -h
Will tell you about your disk

Once mounted you can check your chown permissions. Will need to adjust ownership to www-data for nc to access the location.

Lol ok. I have another pi so I’ll grab that and try with the backup disc and see how I get on.

1 Like