nextcloud snap moving existing data directory to windows shared folder

3 min read 1 month ago
Published on May 17, 2025 This response is partially generated with the help of AI. It may contain inaccuracies.

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

  1. 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.
  2. Note the Shared Folder Path

    • Take note of the network path of the shared folder, which typically looks like \\ComputerName\SharedFolder.

Step 2: Connect Ubuntu Server to the Shared Folder

  1. 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
      
  2. 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
      
  3. 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, and YourPassword with your actual shared folder details.

Step 3: Update Nextcloud Configuration

  1. Change Nextcloud Data Directory

    • Open the Nextcloud configuration file using a text editor:
      sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php
      
  2. 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',
      
  3. Save and Exit

    • Save the changes and exit the text editor (in Nano, press CTRL + X, then Y, and Enter).

Step 4: Move Existing Data

  1. 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/
      
  2. 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
      

Step 5: Automate Mounting of Shared Folder

  1. Edit fstab for Persistent Mounting

    • Open the fstab file:
      sudo nano /etc/fstab
      
  2. 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
      
  3. Test fstab Configuration

    • Test the fstab configuration by running:
      sudo mount -a
      

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.