Nextcloud change where is data store change the path #nextcloud #googledrivealternative #server

 To change the data storage path for Nextcloud, you need to follow a series of steps. This process involves moving your existing data directory to a new location and updating Nextcloud's configuration to point to the new location. Here’s a detailed guide on how to do this:


### 1. **Prepare the New Data Directory**


1. **Create the New Data Directory:**


   First, create the new directory where you want to store your Nextcloud data:


   ```bash

   sudo mkdir -p /path/to/new/nextcloud_data

   ```


   Replace `/path/to/new/nextcloud_data` with the desired path.


2. **Set Correct Permissions:**


   Next, set the proper ownership and permissions for the new directory:


   ```bash

   sudo chown -R www-data:www-data /path/to/new/nextcloud_data

   sudo chmod -R 755 /path/to/new/nextcloud_data

   ```


### 2. **Move Existing Data**


1. **Stop the Web Server:**


   Before moving the data, stop the web server to ensure no files are being accessed:


   ```bash

   sudo systemctl stop apache2

   ```


2. **Move the Data:**


   Move the existing Nextcloud data to the new directory:


   ```bash

   sudo mv /var/www/nextcloud/data/* /path/to/new/nextcloud_data/

   ```


   Ensure the original data directory is empty:


   ```bash

   sudo rmdir /var/www/nextcloud/data

   ```


### 3. **Update Nextcloud Configuration**


1. **Edit the Configuration File:**


   Open the Nextcloud configuration file:


   ```bash

   sudo nano /var/www/nextcloud/config/config.php

   ```


2. **Update the `datadirectory` Path:**


   Find the line with `'datadirectory'` and update it to the new path:


   ```php

   'datadirectory' => '/path/to/new/nextcloud_data',

   ```


3. **Save and Close the File:**


   Save the changes (`CTRL+O`) and exit the editor (`CTRL+X`).


### 4. **Restart the Web Server**


Restart Apache to apply the changes:


```bash

sudo systemctl start apache2

```


### 5. **Verify the New Data Directory**


Log in to your Nextcloud web interface and verify that everything is working correctly. Check if you can see your files and upload new ones without issues.


### Optional: **Update the Old Data Directory (if necessary)**


If you want to keep the old directory as a backup or for any other reason, ensure it's removed or archived securely:


1. **Check Old Directory:**


   Verify the old data directory is empty:


   ```bash

   sudo ls /var/www/nextcloud/data

   ```


2. **Remove or Archive the Old Directory:**


   ```bash

   sudo rm -rf /var/www/nextcloud/data

   ```


### Troubleshooting


- **Permissions Issues:** If you encounter permissions issues, double-check that the `www-data` user has the correct ownership and permissions on the new data directory.


- **Check Logs:** If Nextcloud is not functioning as expected, check the Nextcloud logs (`/var/www/nextcloud/data/nextcloud.log`) and Apache error logs for clues.


- **Database Update:** If you have issues accessing files or the Nextcloud interface, ensure the database is updated properly. Sometimes, a Nextcloud upgrade or change in the data path might require a database scan or repair. You can do this using the Nextcloud command-line tool:


  ```bash

  sudo -u www-data php /var/www/nextcloud/occ files:scan --all

  ```


By following these steps, you should be able to change the data storage path for Nextcloud successfully.

Comments

Popular posts from this blog

SAMBA SERVER 2.0 #server

Setup SSH for accessing outside from network

Speech tools - espeak and festival etc.