mirror of
https://github.com/nmasur/dotfiles
synced 2024-12-24 02:34:52 +00:00
switch nextcloud from sqlite to mysql
This commit is contained in:
parent
7f9ce5925e
commit
57b38a417e
46
docs/repair-nextcloud.md
Normal file
46
docs/repair-nextcloud.md
Normal file
@ -0,0 +1,46 @@
|
||||
# Repairing Nextcloud
|
||||
|
||||
You can run the maintenance commands like this:
|
||||
|
||||
```
|
||||
sudo -u nextcloud nextcloud-occ maintenance:mode --on
|
||||
sudo -u nextcloud nextcloud-occ maintenance:repair
|
||||
sudo -u nextcloud nextcloud-occ maintenance:mode --off
|
||||
```
|
||||
|
||||
Converting from SQLite to MySQL (mariadb)
|
||||
|
||||
First: keep Nextcloud set to SQLite as its dbtype, and separately launch MySQL
|
||||
as a service by copying the configuration found
|
||||
[here](https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/services/web-apps/nextcloud.nix).
|
||||
|
||||
No password is necessary, since the user-based auth works with UNIX sockets.
|
||||
|
||||
You can connect to the MySQL instance like this:
|
||||
|
||||
```
|
||||
sudo -u nextcloud mysql -S /run/mysqld/mysqld.sock
|
||||
```
|
||||
|
||||
Create a blank database for Nextcloud:
|
||||
|
||||
```sql
|
||||
create database nextcloud;
|
||||
```
|
||||
|
||||
Now setup the [conversion](https://docs.nextcloud.com/server/17/admin_manual/configuration_database/db_conversion.html):
|
||||
|
||||
```
|
||||
sudo -u nextcloud nextcloud-occ db:convert-type mysql nextcloud localhost nextcloud
|
||||
```
|
||||
|
||||
Ignore the password prompt. Proceed with the conversion.
|
||||
|
||||
Now `config.php` will be updated but the override config from NixOS will not
|
||||
be. Now update your NixOS configuration:
|
||||
|
||||
- Remove the `mysql` service you created.
|
||||
- Set `dbtype` to `mysql`.
|
||||
- Set `database.createLocally` to `true`.
|
||||
|
||||
Rebuild your configuration.
|
@ -4,15 +4,19 @@
|
||||
|
||||
services.nextcloud = {
|
||||
package = pkgs.nextcloud27; # Required to specify
|
||||
configureRedis = true;
|
||||
datadir = "/data/nextcloud";
|
||||
database.createLocally = true;
|
||||
https = true;
|
||||
hostName = "localhost";
|
||||
maxUploadSize = "50G";
|
||||
config = {
|
||||
adminpassFile = config.secrets.nextcloud.dest;
|
||||
dbtype = "mysql";
|
||||
extraTrustedDomains = [ config.hostnames.content ];
|
||||
trustedProxies = [ "127.0.0.1" ];
|
||||
};
|
||||
extraOptions = { default_phone_region = "US"; };
|
||||
};
|
||||
|
||||
# Don't let Nginx use main ports (using Caddy instead)
|
||||
@ -147,35 +151,10 @@
|
||||
# Grant user access to Nextcloud directories
|
||||
users.users.${config.user}.extraGroups = [ "nextcloud" ];
|
||||
|
||||
## Backup config
|
||||
|
||||
# Open to groups, allowing for backups
|
||||
systemd.services.phpfpm-nextcloud.serviceConfig.StateDirectoryMode =
|
||||
lib.mkForce "0770";
|
||||
|
||||
# Allow litestream and nextcloud to share a sqlite database
|
||||
users.users.litestream.extraGroups = [ "nextcloud" ];
|
||||
users.users.nextcloud.extraGroups = [ "litestream" ];
|
||||
|
||||
# Backup sqlite database with litestream
|
||||
services.litestream = {
|
||||
settings = {
|
||||
dbs = [{
|
||||
path = "${config.services.nextcloud.datadir}/data/nextcloud.db";
|
||||
replicas = [{
|
||||
url =
|
||||
"s3://${config.backup.s3.bucket}.${config.backup.s3.endpoint}/nextcloud";
|
||||
}];
|
||||
}];
|
||||
};
|
||||
};
|
||||
|
||||
# Don't start litestream unless nextcloud is up
|
||||
systemd.services.litestream = {
|
||||
after = [ "phpfpm-nextcloud.service" ];
|
||||
requires = [ "phpfpm-nextcloud.service" ];
|
||||
};
|
||||
|
||||
# Log metrics to prometheus
|
||||
networking.hosts."127.0.0.1" = [ config.hostnames.content ];
|
||||
services.prometheus.exporters.nextcloud = {
|
||||
|
Loading…
Reference in New Issue
Block a user