Change Storage Path of a single user

there is a way to transfer user-Data from one storage path to another via OCC command.

The question here is - can this be done, also for a single user ?
(so - source- & destination user would be the same, but you change the path)

You may transfer all files and shares from one user to another. This is useful before removing a user:

sudo -u www-data php occ files:transfer-ownership
It is also possible to transfer only one directory along with it’s contents. This can be useful to restructure your organization or quotas. The --path argument is given as the path to the directory as seen from the source user:

sudo -u www-data php occ files:transfer-ownership --path=“path_to_dir”

Could you clarify your question?

For example, say you are using the default data storage path of nextcloud/data/ and you have a user with a path of nextcloud/data/someuser, are you asking to be able to move that user’s data directory to a different location like otherfilesystem/someuser?

I’m not certain if nextcloud can follow symlinks, but have you tried? I.e.,

cp -prf nextcloud/data/someuser /otherfilesystem/
ln -sf /otherfilesystem/someuser nextcloud/data/someuser

I’d suggest testing it on a test user before doing it to a real user.

Hey Larry … many thanks for your answer & help! i do appreciate & i love the community here - everyone helps everyone. Nextcloud (and the poeple behind - it’s an incredible great product - made from great poeple).

(yes … this needs said from time to time :smile: )

i do see, you’re quite a Linux cli professional.

What i’m looking for is really for the OCC way. OCC is the common cli-api, which is not necessary in every case - but, when you find a command there, it’s most the “supported” one.

I think, it’s good to know, that Nextcloud has got also a reference from storage-path in the database. So, if one will only move the data to another data-/storage path, this could lead to issues.

Nextcloud has got a “relative” clear statement about in the docs:

if you have a fresh install, consider reinstalling with your preferred directory location.

Unofficially moving the data directory can be done as follows:

  1. Make sure no cron jobs are running
  2. Stop apache
  3. Move /data to the new location
  4. Change the config.php entry
  5. Edit the database: In oc_storages change the path on the local::/old-data-dir/ entry
  6. Ensure permissions are still correct
  7. Restart apache

For a safe moving of data directory, supported by Nextcloud, recommended actions are:

  1. Make sure no cron jobs are running
  2. Stop apache
  3. Move /data to the new location
  4. Create a symlink from the original location to the new location
  5. Ensure permissions are still correct
  6. Restart apache

I think both ways as written in the Nextcloud manual will work, but the preferred way to do (as per recommendation from Nextcloud) is the “Soft-Link” way … i think the reason for is, that for some users … it may be tricky (& dangerous) manipulating the Database.

But what i really want to know/test is - if there is a command (like occ transfer), where you can do that … when i’ve find some time, i can test this on a VBOX.

(i’m quite sure, OCC will change the storage path & the Database entries accordingly)

I’m still very confused about what you are asking. In your first post, you asked specifically about moving a SINGLE USER (“The question here is - can this be done, also for a single user ?”), not the entire data directory. Now in your second post you are ignoring single user and asking about moving the entire data directory, and not only that, but you’ve answered your own question and come up with TWO METHODS of accomplishing the objective.

That’s what the symbolic link is for, so that even though it is in a different place, it will still be accessible using the SAME path as before.

Why do you need an “occ” command to handle something basic that can be handled by the operating system? The purpose of “occ” is to address things that the operating system doesn’t have a handle on – the database.

Now in regards to moving the ENTIRE data directory, you do NOT need to muck around with the database at all. Just change the path in config.php. Nextcloud will automatically create a new entry in the oc_storages table and everything will just magically work.

No, my question was clear from the beginning:
“is there a way to transfer user-Data from one storage path to another via OCC command.”

you did refer to cp & ln -sf on user base, right, left out all the stuff with the database … I was referring - in general - to the “cp & ln -s” commands in relation to data migrations.

I think the Nextcloud Admin context clearly shows that there is also a database reference, because each file has to be referenced via database with the storage path.

I had once done exactly that many years ago after a hardware change (for testing purposes) - only changed the data directory in config.php and saw that the gui could no longer access various files because the database had referenced a different path.

have a look to this threat (and they are many of them) →

HowTo: Change / Move data directory after installation - :bookmark_tabs: How to - Nextcloud community

Again my question was really ONLY related to OCC → can i move the same user to another storage path.

sudo -u www-data php occ files:transfer-ownership --path=“path_to_dir”

Normally this command is intended using for two different users … i was just wondering, if this works with the same user …

but it may also be that my question is too hypotethical … I will test it out

$ ./occ files:transfer-ownership user1 user2
Analysing files of user1 …
5179 [============================]
Collecting all share information for files and folder of user1 …
3 [============================]
Transferring files to user2/files/transferred from user1 on 2018-07-09 15-38-56 …
Restoring shares …
Share with id 198 points at deleted file, skipping
1/3 [=========>------------------] 33%Share with id 316 points at deleted file, skipping
2/3 [==================>---------] 66%Share with id 317 points at deleted file, skipping
3/3 [============================] 100%

Tested → Ownership can’t be transferred when Source and Destination users are the same user. Please check your input.