* The cover image is officially released.
Summary
NextCloud is an open-source self-hosted file share platform forked from ownCloud.
I had to transfer the ownership of shared files/directories due to personnel change the other day.
A simple way was to download all the files and then upload them by the new owner.
But it was too impractical as they were so big.
Alternatively, I carried it out via command lines with occ
.
occ
is NextCloud's command-line interface to perform server operations whose name is after "o"wn"C"loud (the origin) "C"onsole.
Environment
Tutorial
The command of occ
to use is Files
' transfer-ownership
The basic format is:
$ occ files:transfer-ownership <from-user> <to-user>
In my environment, occ
didn't exist among PATH
environment variable.
Therefore, I used find
to get the path, and specify it in the command line as <lib-dir-path>/occ
.
Additionally, I had to run it with specified PHP.
$ php73 <lib-dir-path>/occ files:transfer-ownership <from-user> <to-user>
Finally, it was required to run as the web user, apache
in my case:
$ sudo -u apache php73 <lib-dir-path>/occ files:transfer-ownership <from-user> <to-user>
The output was:
Analysing files of <from-user> ...
16442 [============================]
Collecting all share information for files and folder of <from-user> ...
25 [============================]
Transferring files to <to-user>/files/transferred from <from-user> on 2019-06-12 01-56-02 ...
Restoring shares ...
Share with id 4 points at deleted file, skipping
1/25 [=>--------------------------] 4%Share with id 11 points at deleted file, skipping
2/25 [==>-------------------------] 8%Share with id 12 points at deleted file, skipping
3/25 [===>------------------------] 12%Share with id 16 points at deleted file, skipping
7/25 [=======>--------------------] 28%Share with id 1 points at deleted file, skipping
8/25 [========>-------------------] 32%Share with id 9 points at deleted file, skipping
13/25 [==============>-------------] 52%Share with id 90 points at deleted file, skipping
14/25 [===============>------------] 56%Share with id 91 points at deleted file, skipping
15/25 [================>-----------] 60%Share with id 28 points at deleted file, skipping
19/25 [=====================>------] 76%Share with id 57 points at deleted file, skipping
20/25 [======================>-----] 80%Share with id 58 points at deleted file, skipping
21/25 [=======================>----] 84%Share with id 60 points at deleted file, skipping
22/25 [========================>---] 88%Share with id 61 points at deleted file, skipping
23/25 [=========================>--] 92%Share with id 87 points at deleted file, skipping
24/25 [==========================>-] 96%Share with id 88 points at deleted file, skipping
25/25 [============================] 100%
As a result, a new directory named "transferred from <from-user> on 2019-06-12 01-56-02" (printed in the console) was created in <to-user>'s home and all the files were owned by the new owner there.
All I had to do then was to log in as <to-user> and move them as needed : )
References
- NextCloud's "Transferring files to another user"
- Other commands
Thank you for your reading.
Happy serving.