How to do a CLI installation with an existing data directory and database

Hello,

I am using ansible to automate my nextcloud installation, so I am installing via the occ command.

My setup is such that I have a VM with a remote database server and a mountpoint for my owncloud data dir. If I recreate my VM and re-run the occ install command I get an error saying the admin user’s data directory has files present.

What is the best solution to this workflow of reinstalling nextcloud with an existing data directory? I have tried as many hacks as I can think of such as bypassing install completely without any luck.

I feel like I must be missing something, I can’t be the only person doing this right? :laughing:

Thanks!

So you restore some kind of default setup?
https://docs.nextcloud.com/server/stable/admin_manual/maintenance/restore.html

I would like to avoid having to do a database backup & transfer of my whole data directory every time. I already have the database untouched on another machine and my data directory is mounted from my zfs pool.

I guess I could set the data directory to a temporary path and do the install then change the setting? I haven’t tried that yet as it feels like it could be prone to trouble?

Or you just need to mount the storage, put the right config.php and that’s all, no?

I think “put the right config.php” is the bit that’s causing me issues. Is that all that the important stuff the occ maintenance:install command does?

I think you just place the code of NC, and then put the suitable config.php.