Personally i think it is not a good solution to use symbolic links over partitions for the nextcloud data dir. Then the nextcloud config/config.php does not really need an entry for data-dir and you always can use ādataā Perhaps it is a risk for data-backup over symbolic links and partitions with e.g. tar.
It is a āquick and easyā solution if one feels uncomfortable to alter the database manually. However for Nextcloud access the symlinks do not make a difference. Other direct access should only be done for backup purpose and I would always have the backup tool syncing/copying from the actual location, not the symlink, yes.
Then the nextcloud config/config.php does not really need an entry for data-dir and you always can use ādataā
Exactly, as long as the underlying file system supports symlinks. But, as mentioned in the HowTo, this implies the theoretical security weakness that in case of misconfigured webserver those files could be directly accessible. Very theoretical indeed since the included .htaccess
denies it for all Apache versions 2.2 and up, the Nginx example config from docs contains the block as well and in case there is an admin panel warning when /path/to/nextcloud/data
is directly accessible.
But of course a thought through setup always implies the data dir outside of webroot/nextcloud dir right from the beginning so that the data dir does not need to be moved. This HowTo is for the cases where the setup was not ideal right from the beginning or environment has simply changed. Solution 1 is always the preferred one to have a consistent definit change, Solution 2 practically āworksā and is easier and faster to apply.
I know this is a super old post but I was hoping you could help out, I was following your solution 1 fine, had to find the default paths for many items and it was actually going well until step 6:
mysqldump -u<rootuser> -p > /path/to/dbdump/dump.sql
I for the life of me canāt find what I should be putting there assuming a default path. Iāve scoured the web and canāt find mysql dump.
This is the path+filename to where your backup will be stored. So choose anything you like, preferably an external backup HDD where you usually store backups regularly (which you should). Before youāre thinking too long, your users home dir will work fine for now:
mysqldump -uroot -p > ~/database_backup.sql
Depending on the system you use, the root user might use a socket authentication plugin, which means that you need to do the step in a root user session without password:
sudo -s
mysqldump > /database_backup.sql
chmod 666 /database_backup.sql
exit
mv /database_backup.sql ~/database_backup.sql
This opens an interactive root user shell, stores the database dump to the drive root (since I donāt know your UNIX user name or home dir), grants anyone fill access, exits the root session and then moves the dump to the originating users home dir.
Okay so I got that far, did your steps and it went fine. Iām running ubuntu 18.04 server, username is jamess7995. So i moved onto step 7, and I was attempting to open the file and was getting what seemed like a permisson issue where it wouldnāt accept any login, so I ended up following this article on treating it like forgotten/unknown root password, even though I knew it. and I was unable to start mysql backup, until a restart. But then Iāve run this:
jamess7995@leviathan:~$ mysql -u jamess7995 -p
Enter password:
ERROR 1045 (28000): Access denied for user ājamess7995ā@ālocalhostā (using password: YES)
And Iām back to square one of this permission issue
Ah, you do not use your UNIX user to login to MySQL, as it has its own internal user management. Use the root
user as you did with mysqldump
:
mysql -uroot -p
or probably required for the same reason as with mysqladmin:
sudo -s
mysql
# ... do the steps in MySQL console
exit
The root user is actually the only overlap that exist, since on Debian (and AFAIK Ubuntu) it exists as MySQL admin user as well and is implemented with a plugin that allows (only) the root UNIX user to login without password. But otherwise the user management is completely independent from the systems UNIX users.
@MichaIng Please change the link to https://www.hanssonit.se/nextcloud-vm/ and the name from Tech and Me to Hansson IT.
Thanks!
Done
BTW, depending on environment/circumstances, I guess another option to achieve this goal might be to leave the data directory in place and just move the rest (i.e. the PHP files, resources, etc.) to a new document root?
can someone please clarify the correct permissions for the data folder and for the underling directorys?
Thanks.
What is your question here? In short words. The user running the webserver needs access to the data directory.
Thanks, I ran into the same issue - I am presuming that I can leave the old location in the database?
in my case **/var/www/nextcloud/data-nc/ ** was the old location during the installation and I have since migrated to a separate drive partition via /media/nextcloud-data.
Just feels a little untidy and I would like to delete the /var/www/nextcloud/data-nc/ location, if I do so will NC simpley mark it as unavailable and work fine?
MariaDB [nextcloud]> select * from oc_storages;
+------------+------------------------------------+-----------+--------------+
| numeric_id | id | available | last_checked |
+------------+------------------------------------+-----------+--------------+
| 1 | local::/var/www/nextcloud/data-nc/ | 1 | NULL |
| 2 | home::user1 | 1 | NULL |
| 3 | home::user2 | 1 | NULL |
| 4 | home::user3 | 1 | NULL |
| 5 | home::user4 | 1 | NULL |
| 6 | home::user5 | 1 | NULL |
| 7 | home::user6 | 1 | NULL |
| 8 | home::user7 | 1 | NULL |
| 9 | local::/media/nextcloud-data/ | 1 | NULL |
+------------+------------------------------------+-----------+--------------+
You can simply delete it, check this out Files amount after moving of data directory is wrong (much bigger)
I took a slightly different approach to moving data, by creating a mirrored RAID on my Pi 4 with (2) 128G SSDās.
Following this a a guide I created the mirrored RAID:
With the RAID initially mounted on /mnt I copied all folders from /var/www to /mnt and changed folder permissions and ownership to match.
When I added the RIAD to /etc/fstab I referenced /var/www instead of /mnt and rebooted.
The new RAID mount obscures the original folders in /var/www (even though I renamed all prefixed with _) and used the folders copied above.
So far, everything seems ok with no glitches!
Hi all, if someone could give me a hand on how to move data out of the VM to external hard drive (shared drive from windows) and autoupload to this external hard drive then it would be great.
My SSD is running out of spaceā¦ Sorry for waking an old postā¦
Hello
I am running a Raspberry 4 with an USB disk which I want to replace. On the disk is only the data not the database. I am running the newest version of NextcloudPi.
So what I did:
rsync -rav /old-disk /new-disk
service apache2 stop
edited config.php 'datadirectory'
unplug old disk
sudo -u www-data php /var/www/nextcloud/occ files:scan --all
service apache2 start
Now I have a big problem:
- if I upload a small text file, eveything is ok.
- But if I try to upload a bigger file like 1MB picture, I get an error. All bigger uploads are broken. Fron the mobile app, from the desktop client, from the browser.
- If I plug in the old disk, everything (upload of bigger files) works again.
- The error from the server log is very cryptic and very long. The client says āconnection closedā.
I did a file search and found the old paths in these files:
/etc/php/7.3/fpm/conf.d/10-opcache.ini
/etc/php/7.3/fpm/conf.d/10-opcache.ini
/etc/php/7.3/fpm/php.ini
/etc/php/7.3/fpm/php.ini
/etc/php/7.3/mods-available/opcache.ini
/etc/php/7.3/cli/conf.d/10-opcache.ini
/etc/php/7.3/cli/php.ini
/etc/fail2ban/jail.local
/etc/fail2ban/jail.conf
I replaced the path in there files, restarted apache, but no change. The old disk is still needed.
Has somebody a tip?
Thanks very much
Gilbert
EDIT:
I solved the problem by myself. Like always with Nextcloud and this forum. If somebody has a similar question/problem, how to replace the usb data disk on a raspberry pi, this is what I have done:
date; rsync -rav /media/myCloudDrive/ncdata/ /media/myCloudDriveNew/ncdata/; date;
service apache2 stop
sudo btrfs filesystem label '/media/myCloudDrive/' 'myCloudDriveOld'
sudo restart
service apache2 stop
sudo btrfs filesystem label '/media/myCloudDriveNew/' 'myCloudDrive'
sudo restart
unplug the old small usb disk
My disks are formatted with btrfs. If you have another file system, you have to google for the command for renaming the label.
Good luck!
Thanks for this guide - very helpful. For me, symlink didnāt work no matter how I tried. On Ubuntu server 20.04 LTS (raspberry pi version) and 20.0.5 nextcloud.
What did work was mount --bind, from this post: [Solved] Nextcloud, change Data folder location / Newbie Corner / Arch Linux Forums
Took a long time to finally get there but I did.
Thanks for the feedback. Probably the file system does not support symlinks, like FAT-family or NTFS (without ntfs-3g driver)? The bind mount is a good alternative in such case, but it means that an additional fstab entry or mount call is required while a symlink works on itās own.
Interestingā¦ The target is on a ext4-formatted LUKS drive while the original/default place is on an ext4-formatted SSD on a raspberry pi. I honestly donāt know what was wrong. Yes it will be an additional command each time I reboot.
Strange indeed then. Does the symlink creation produce any error and does it show up correctly in the file system? E.g.:
ln -s /mnt/external/ncdata /var/www/nextcloud/testlink
ls -l /var/www/nextcloud/testlink
If you use Apache2, is Options +FollowSymLinks
allowed for the Nextcloud web dir? Although if not, also rewrites would be broken.