Skip to content

Instantly share code, notes, and snippets.

@jessegoodier
Last active September 30, 2022 16:49
Show Gist options
  • Save jessegoodier/f0b3ced1dde09ae28e0fd745d2b249e1 to your computer and use it in GitHub Desktop.
Save jessegoodier/f0b3ced1dde09ae28e0fd745d2b249e1 to your computer and use it in GitHub Desktop.
Steps to install nextcloud on ubuntu using snap and moving the data to a new disk using zfs compression and deduplication
# sample code, use at your own risk
# script to install zfs, nextcloud using snap and moving the data to the new volume with compression and deduplication enabled.
# Do your own research as to pros and cons of zfs dedupe and compression.
# Short advice is that compression works well unless you're mostly storing compressed file formats like media.
# install and configure zfs, assuming 2nd disk is where you want your data stored.
sudo apt install zfsutils-linux
sudo zpool create nextcloud /dev/sdb
sudo zfs create nextcloud/data
sudo zfs set compression=lzjb nextcloud/data
sudo zfs set dedup=on nextcloud/data
sudo zfs set mountpoint=/media/nextcloud nextcloud/data
# install and configure nextcloud:
sudo snap install nextcloud
sudo snap connect nextcloud:removable-media
sudo nextcloud.manual-install admin findABetterPassword
sudo nextcloud.occ config:system:set trusted_domains 1 --value=nextcloud-test
sudo snap stop nextcloud
sudo vi /var/snap/nextcloud/current/nextcloud/config/config.php # edit 'datadirectory' => '/media/nextcloud/data'
sudo mv /var/snap/nextcloud/common/nextcloud/data /media/nextcloud/
sudo snap start nextcloud
# Good article on configuring using snap here:
# https://medium.com/@dbclin/administrating-nextcloud-as-a-snap-4eb43ca6d095
# Documentation on changing the data dir:
# https://github.com/nextcloud/nextcloud-snap/wiki/Change-data-directory-to-use-another-disk-partition
# notes for checking data sizes:
sudo du --si --max-depth=2 /media/nextcloud
zpool list
sudo zfs get all | grep compress
sudo zfs get all | grep dedupe
# note nextcloud.export will fail, need to create link to new dir:
# sudo ln -s /media/nextcloud/data /var/snap/nextcloud/common/nextcloud/data
# nextcloud cli client:
# sudo add-apt-repository ppa:nextcloud-devs/client
# sudo apt update
# sudo apt install nextcloud-client
# sync subdir using cli (create sub-dir via web gui first):
# nextcloudcmd -u username -p password! /etc/nginx/ https://nextcloud.example.com/remote.php/webdav/nginx
@ou85
Copy link

ou85 commented Sep 29, 2022

Great walk-through.
Exactly what I have been searching for.
Works perfect.
Thank you.

@jessegoodier
Copy link
Author

Thank you for the note! Glad it helped somone-

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment