Nextcloud Storing Data on NAS
Mounting the data dir as a SMB share from my Synology NAS.
Creating a Mountpoint to NAS/nextcloud-data
To ensure the data from the NAS is available to the container, we have to mount the nextcloud-data
directory via SMB on my docker server.
cd ~/nextcloud
sudo mount -t cifs "//NAS/nextcloud-data/data" \
-o username="admin" \
-o uid=www-data,gid=www-data \
-o file_mode=0640,dir_mode=0770 \
data
# create symlink to mounted data
ln -s /media/nas/nextcloud-data/data data
Auto Mounting nextcloud-data on Startup
Place following line into /etc/fstab
.
# nextcloud data directory on Synology NAS
//NAS/nextcloud-data /media/nas/nextcloud-data cifs rw,username=admin,password=*****,uid=33,forceuid,gid=33,forcegid,addr=NAS_IP,file_mode=0640,dir_mode=0770,x-systemd.automount 0 0
- Manually mount fstab mounts with
sudo mount -a
. - The
x-systemd.automount
will wait until the network is available before trying to establish the mount
Remounting nextcloud-data on Restart
If the server restarts, the mount point is lost. Therefore you can
- add cronjob to remount fstab with
crontab -e
every hour
# At minute 0 past every 3rd hour, remount drives just in case of outage
0 */1 * * * mount -a