Change Nextcloud data location

Guide: Change Data Storage Location for Nextcloud Docker Installation

This guide will help you change the data storage location for your Nextcloud Docker installation to different disk mounted as /mnt/tank/

Step 1: Stop the Nextcloud Container

  1. Use right click stop in Umbrel WebUI

Step 2: Create new partition and new data directory

  1. Install xfsprogs
sudo apt update
sudo apt install xfsprogs
  1. Format and mount the partition as XFS:
sudo mkfs.xfs /dev/sdb1
sudo mount /dev/sdb1 /mnt/tank
  1. Create the new directory for Nextcloud data:
sudo mkdir -p /mnt/tank/nextcloud
  1. Set the correct permissions:
sudo chown -R www-data:www-data /mnt/tank/nextcloud

Step 3: Identify the Current Data Directory (start, run inspect, and stop again nextcloud)

  1. Inspect the Nextcloud container to find the current data directory:
docker inspect nextcloud_web_1
  1. Look for the Mounts section in the output. It will show the current source (host) and destination (container) paths for the data volume. For example:
"Mounts": [
    {
        "Type": "bind",
        "Source": "/home/umbrel/umbrel/app-data/nextcloud/data/nextcloud",
        "Destination": "/var/www/html",
        "Mode": "rw",
        "RW": true,
        "Propagation": "rprivate"
    }
]
  • Source is the current data directory on the host (e.g., /home/umbrel/umbrel/app-data/nextcloud/data/nextcloud).

  • Destination is the mount point inside the container (e.g., /var/www/html).

Step 4: Copy Existing Data to the New Location (This might take a while)

  1. Copy the existing Nextcloud data to the new location using rsync:
sudo rsync -av /home/umbrel/umbrel/app-data/nextcloud/data/nextcloud/ /mnt/tank/nextcloud/`
  1. Verify the data has been copied:
ls -la /mnt/tank/nextcloud

Step 5: Update the Docker Configuration

  1. Open the docker-compose.yml file:
sudo nano /home/umbrel/umbrel/app-data/nextcloud/docker-compose.yml
  1. Locate the volumes section for the web service and update it:
volumes:
  - /mnt/tank/nextcloud:/var/www/html
  1. Save and exit the file.

Step 6: Restart the Nextcloud Container

  1. Use right click restart in Umbrel WebUI

Step 7: Verify the Changes

  1. Log in to the Nextcloud web interface.

  2. Verify that all files, folders, and apps are accessible.

  3. Upload a new file and confirm it appears in /mnt/tank/nextcloud/data/umbrel/files.

Step 8: Clean Up the Old Data Directory (Optional)

  1. Delete the old data directory to free up space:
sudo rm -rf /home/umbrel/umbrel/app-data/nextcloud/data/nextcloud

Step 9: Ensure Persistent Mount After Reboot

  1. Find the UUID of /dev/sdb1:
sudo blkid /dev/sdb1
  1. Edit the /etc/fstab file:
sudo nano /etc/fstab
  1. Add the following line to the end of the file:
    UUID=<YOUR DISK UUID> /mnt/tank xfs defaults 0 2
    example: UUID=1190bd87-aa96-4993-8413-1c1da928fc77 /mnt/tank xfs defaults 0 2

  2. Save and exit the file.

Step 10: Final Verification

  1. Reboot the system

  2. After reboot, verify that /dev/sdb1 is mounted to /mnt/tank:

df -h /mnt/tank
  1. Check that Nextcloud is functioning correctly.

Troubleshooting

  • If the container fails to start, check the logs:
    docker logs nextcloud_web_1

  • If the mount fails after reboot, verify the /etc/fstab entry and check for errors in the system logs:
    journalctl -xe

  • If you update you need to do this again

3 Likes

Great tutorial! Thanks for this!

1 Like

I used this guide but I got 2 errors.

Summary

An exception occured while running the setup check: InvalidArgumentException: URL is missing scheme or host in /var/www/html/lib/public/SetupCheck/CheckServerResponseTrait.php:154 Stack trace: #0 /var/www/html/lib/public/SetupCheck/CheckServerResponseTrait.php(84): OCA\Settings\SetupChecks\WellKnownUrls->normalizeUrl(‘https://fd0b:10…’, true) #1 /var/www/html/lib/public/SetupCheck/CheckServerResponseTrait.php(116): OCA\Settings\SetupChecks\WellKnownUrls->getTestUrls(‘/.well-known/we…’, true) #2 /var/www/html/apps/settings/lib/SetupChecks/WellKnownUrls.php(57): OCA\Settings\SetupChecks\WellKnownUrls->runRequest(‘get’, ‘/.well-known/we…’, Array, true) #3 /var/www/html/lib/private/SetupCheck/SetupCheckManager.php(34): OCA\Settings\SetupChecks\WellKnownUrls->run() #4 /var/www/html/apps/settings/lib/Controller/CheckSetupController.php(132): OC\SetupCheck\SetupCheckManager->runAll() #5 /var/www/html/lib/private/AppFramework/Http/Dispatcher.php(205): OCA\Settings\Controller\CheckSetupController->check() #6 /var/www/html/lib/private/AppFramework/Http/Dispatcher.php(118): OC\AppFramework\Http\Dispatcher->executeController(Object(OCA\Settings\Controller\CheckSetupController), ‘check’) #7 /var/www/html/lib/private/AppFramework/App.php(153): OC\AppFramework\Http\Dispatcher->dispatch(Object(OCA\Settings\Controller\CheckSetupController), ‘check’) #8 /var/www/html/lib/private/Route/Router.php(321): OC\AppFramework\App::main(‘OCA\\Settings\\Co…’, ‘check’, Object(OC\AppFramework\DependencyInjection\DIContainer), Array) #9 /var/www/html/lib/base.php(1155): OC\Route\Router->match(‘/settings/ajax/…’) #10 /var/www/html/index.php(25): OC::handleRequest() #11 {main}

Summary
echnical information
=====================
The following list covers which files have failed the integrity check. Please read
the previous linked documentation to learn more about the errors and how to fix
them.

Results
=======
- core
	- INVALID_HASH
		- .htaccess

Raw output
==========
Array
(
    [core] => Array
        (
            [INVALID_HASH] => Array
                (
                    [.htaccess] => Array
                        (
                            [expected] => 418f0babf39f82e537d12028229189633a7941160c27c3410032af498008a65637b8d1ee64abc63a6321c3d1ef8cde31fe58cee00d8b32821480501111977c34
                            [current] => 7bbf9de971f4089569e419283ed84395ec49f2f5557cd5d65c70dd65c65b91075bb8f0a1c83ceb209afa351fed04f6fedf5f135ff35df9f033ef9494a7b2c967
                        )

                )

        )

)