# Nextcloud Snap install and S3 Storage Bucket

### [Github Page](https://github.com/nextcloud/nextcloud-snap)

## How to install (these have to be run as root):

1. Make sure it's a fresh install and unplug all devices connected to the instance if the case:

```bash
snap remove nextcloud
```

1. Install nextcloud:

```bash
snap install nextcloud
```

1. Add storage.config.php file with S3 bucket to `/var/snap/nextcloud/current/nextcloud/config`

```php
<?php
$CONFIG = array (
'objectstore' => array(
        'class' => '\\OC\\Files\\ObjectStore\\S3',
        'arguments' => array(
                'bucket' => 'NAME_OF_BUCKET',
                'autocreate' => true,
                'key'    => 'BUCKET_KEY',
                'secret' => 'BUCKET_SECRET',
                //'hostname' => 's3.us-west-1.wasabisys.com',
                'region' => 'BUCKER_REGION',
                'port' => 443,
                'use_ssl' => true,
                'use_path_style'=>true
        ),
),
);
```

**Note: This will be created with programatic AWS user if the bucket does not exist**

**Note 2: If files have not generated after snap install nextcloud, start and stop nextcloud or try installing again**

1. Configure user manually via snap: (change the password after)

```bash
/snap/bin/nextcloud.manual-install USERNAME PASSWORD
```

1. Add allowed domains to `config.php` in `/var/snap/nextcloud/current/nextcloud/config`

```php
  array (
    0 => 'localhost',
    1 => 'internet.domain.com',
    2 => 'nextcloud.lan',
```

1. Update below line with Internet URL:

```bash
  'overwrite.cli.url' => 'https://nextcloud.example.com',
```

1. Restart nextcloud:

```bash
snap restart nextcloud
```

1. Set up certificate either via Let's Encrypt or self-signed

```bash
/snap/bin/nextcloud.enable-https lets-encrypt
/snap/bin/nextcloud.enable-https self-signed
```

#### Let's Encrypt:

1. Point DNS to Server Public IP
2. Make sure port `80` and `443` are open
3. Run command:

```bash
sudo nextcloud.enable-https lets-encrypt
```

To confirm that HTTPs works correctly, point your browser to `https://<your subdomain>`. You should see the Nextcloud login page.

Aaaand that’s it. Now you can install the Nextcloud client and point it to your subdomain to sync files and folders directly to your hard-drive.

1. Restart nextcloud

```bash
snap restart nextcloud
```

2\. Increase upload size:

Since snap manages the app, one is not able to directly commit changes, it has to do through snap itself. Given the options and commands available in this app, one can just replace underscores with dashes after php in the name of the parameter, like:

```php
    php.upload-max-filesize
    php.post-max-size
    php.max-input-time
    php.max-execution-time
```

And then for the upload size: `snap set nextcloud php.post-max-size=16G` or `sudo` if is system-wide.

```bash
snap set nextcloud php.upload-max-filesize=16G
snap set nextcloud php.post-max-size=16G
```

## Joplin export:

* Export Joplin to Raw Folder
* Upload folder to nextcloud
* Go on local Joplin Device and navigate to options and syncronization
* Go to advanced options and click `Delete local data and re-download from sync target`&#x20;

{% hint style="info" %}
**Note: This will have to be updated with new app passwords since MFA is active for user**
{% endhint %}

## Data migration:

* Upload Nextcloud backup or data to Nextcloud via web interface
* Delete all local `Nextcloud` folders after upload successful
* Set up sync clients on devices

**Note: If there are any issues with the sync client, update this parameter:**

```php
"overwriteprotocol" => "https"
```

* After restart nextcloud:

```bash
snap restart nextcloud
```

### SNAP Commands for Nextcloud:

OCC:

```bash
# This will list all the OCC commnads for Nextcloud
/snap/bin/nextcloud.occ 
```

Disable 2FA

```bash
/snap/bin/nextcloud.occ twofactorauth:cleanup totp
```
