nextcloud snap moving existing data directory to windows shared folder
Table of Contents
Introduction
In this tutorial, we will guide you through the process of moving your Nextcloud snap data directory to a Windows shared folder. This method offers benefits such as easier backups and management, especially in virtualized environments. By following these steps, you can enhance your data management processes and streamline your workflow.
Step 1: Prepare the Windows Shared Folder
-
Create a Shared Folder on Windows
- On your Windows machine, create a folder that you want to use as the shared directory for Nextcloud data.
- Right-click the folder, select 'Properties', and go to the 'Sharing' tab.
- Click on 'Share' and add the user accounts that will need access. Make sure to set permissions to allow read/write access.
-
Note the Shared Folder Path
- Take note of the network path of the shared folder, which typically looks like
\\ComputerName\SharedFolder
.
- Take note of the network path of the shared folder, which typically looks like
Step 2: Connect Ubuntu Server to the Shared Folder
-
Install Necessary Packages
- Open your terminal on the Ubuntu server where Nextcloud is running.
- Install the CIFS utilities to enable the connection to the Windows share by executing the following command:
sudo apt-get update sudo apt-get install cifs-utils
-
Create a Mount Point
- Choose a location in your Ubuntu file system where you want to mount the Windows shared folder. For example:
sudo mkdir /mnt/nextcloud_data
- Choose a location in your Ubuntu file system where you want to mount the Windows shared folder. For example:
-
Mount the Windows Share
- Use the following command to mount the shared folder:
sudo mount -t cifs //ComputerName/SharedFolder /mnt/nextcloud_data -o username=YourUsername,password=YourPassword
- Replace
ComputerName
,SharedFolder
,YourUsername
, andYourPassword
with your actual shared folder details.
- Use the following command to mount the shared folder:
Step 3: Update Nextcloud Configuration
-
Change Nextcloud Data Directory
- Open the Nextcloud configuration file using a text editor:
sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php
- Open the Nextcloud configuration file using a text editor:
-
Modify the Data Directory Path
- Find the line that specifies the data directory and change it to the new mount point:
'datadirectory' => '/mnt/nextcloud_data',
- Find the line that specifies the data directory and change it to the new mount point:
-
Save and Exit
- Save the changes and exit the text editor (in Nano, press
CTRL + X
, thenY
, andEnter
).
- Save the changes and exit the text editor (in Nano, press
Step 4: Move Existing Data
-
Copy Existing Data
- If you have existing data in the original Nextcloud data directory, copy it to the new location:
sudo rsync -av /var/snap/nextcloud/common/nextcloud/data/ /mnt/nextcloud_data/
- If you have existing data in the original Nextcloud data directory, copy it to the new location:
-
Set Permissions
- Ensure that the permissions on the shared folder are correctly set so that Nextcloud can access the files:
sudo chown -R www-data:www-data /mnt/nextcloud_data
- Ensure that the permissions on the shared folder are correctly set so that Nextcloud can access the files:
Step 5: Automate Mounting of Shared Folder
-
Edit fstab for Persistent Mounting
- Open the fstab file:
sudo nano /etc/fstab
- Open the fstab file:
-
Add Mount Entry
- Add the following line at the end of the file to ensure your shared folder mounts automatically on boot:
//ComputerName/SharedFolder /mnt/nextcloud_data cifs username=YourUsername,password=YourPassword,uid=www-data,gid=www-data 0 0
- Add the following line at the end of the file to ensure your shared folder mounts automatically on boot:
-
Test fstab Configuration
- Test the fstab configuration by running:
sudo mount -a
- Test the fstab configuration by running:
Conclusion
By following these steps, you have successfully moved your Nextcloud data directory to a Windows shared folder. This setup can simplify data management and backups significantly. Ensure to regularly check the connection and permissions to avoid access issues. If you need further assistance, consider consulting the Nextcloud community or documentation for more advanced configurations.