Owncloud

From Wildsong Wiki
Jump to: navigation, search

See also Synology Cloud Station

What is it?

ownCloud lets me run my own cloud-based file sync so that I don't need to use DropBox. I actually like DropBox but I want unlimited storage space and more security. I still use Dropbox to share files with people outside my organizations.

I now run owncloud on a personal server for my own data and on a Synology server for work.

All the information and downloads are here: https://owncloud.org/

What can I do with it?

Aside from syncing files, I want to answer these questions.

  1. How does versioning work?
  2. Can I make calendar sync work between computer and phone?
  3. Can I use it to maintain contacts database?
  4. Can I get that Dropbox feature where new photos on my phone get uploaded?
  5. How does the photo gallery feature work?

Selective sync

I use create separate document and media spaces (folders) and in the client on each computer I decide which folders to sync. On the laptop I use for casual Internet access I don't need a complete copy of all my GIS data, so I uncheck that folder in the client settings.

Server installation notes

Dockerization (2017 update)

I am run nginx as my web server, which means PHP runs as a separate process under FPM. I tried the "official" FPM version but have not been able to see the point of that, it's a comprehension issue. :-) The official version runs on Apache so I found a different one that runs on nginx (smaller memory footprint.) Then I found out that image (pschmitt/owncloud) is based on older versions than I was running and that means it won't start up. (It can't move backwards and use my upgraded 9.1 database with older 9.1 code.)

I keep the data in mysql. I dockerized it to make it easier to connect this docker to it. See the MySQL page.

Note please : the dockerized nginx server is not SSL; the proxy is. So the message from the owncloud docker that SSL is disabled is OKAY.

See /lib/systemd/system/docker-owncloud.service for how it's started.

Note that it depends on docker-mysql.service, get the MySQL service running first then come back here.

After seting up mysql docker and configuring entries in /etc/hosts, running on Bellman under Debian 9 Linux looks like this:

/usr/bin/docker run --name=owncloud --hostname=owncloud.wildsong.biz -p 88:80   \
--link db -e 'DB_NAME=owncloud'  -e 'DB_USER=owncloud' -e 'DB_PASS=secret' \
-e 'ADMIN_USER=admin' -e 'ADMIN_PASS=another secret'-e 'TIMEZONE=Americas/Los_Angeles' \
-e 'HTTPS_ENABLED=false' -v /green/owncloud/config:/var/www/owncloud/config  \
-v /green/owncloud/data:/var/www/owncloud/data   brian32768/owncloud:9.1

After setting up dnsmasq (with entries for owncloud) and mysql dockers, running on Murre under Windows 10 looks like this:

/usr/bin/docker run --name=owncloud --hostname=owncloud.wildsong.biz -p 88:80   \
--link db -e 'DB_NAME=owncloud'  -e 'DB_USER=owncloud' -e 'DB_PASS=secret' \
-e 'ADMIN_USER=admin' -e 'ADMIN_PASS=another secret'-e 'TIMEZONE=Americas/Los_Angeles' \
-e 'HTTPS_ENABLED=false' -v "O:/owncloud/config:/var/www/owncloud/config"  \
-v "O:/owncloud/data:/var/www/owncloud/data" brian32768/owncloud:9.1

Connecting from command lines

You can use the owncloud command to check status, for example

docker exec owncloud occ status
 - installed: true
 - version: 9.1.6.2
 - versionstring: 9.1.6
 - edition: 

After my initial dockerization I had to "upgrade" even though the versions were the same. I used this command:

docker exec owncloud occ upgrade

SSL Certificate

Once upon a time, I bought the "Positive SSL" certificate from http://comodosslstore.com/ for about $7/year and I paid for 3 years up front.

Now I use LetsEncrypt.

  • Make a folder and put it in the www-data group: sudo mkdir /var/www/letsencrypt && sudo chgrp www-data /var/www/letsencrypt
  • Point nginx at the folder so that letsencrypt can find it by putting this in sites-available/bellman.conf
        location /.well-known/acme-challenge {
            root /var/www/letsencrypt;
        }
  • Install the apt-package letsencrypt
  • Set up a config file, /etc/letsencrypt/configs/owncloud.conf
  • Run this: certbot --config /etc/letsencrypt/configs/owncloud.conf certonly
  • Repeat previous two steps for other SSL certificates you need.
  • Put this in nginx owncloud.conf
# Act as a proxy for owncloud docker

server {
    listen 443 ssl;
    server_name owncloud.wildsong.biz;
    location / {
        proxy_pass http://172.17.0.3/;
    }	   

    ssl_certificate /etc/letsencrypt/live/owncloud.wildsong.biz/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/owncloud.wildsong.biz/privkey.pem;
}
  • Set up a monthly cron script to renew
#!/bin/sh                                                                                                           
for conf in /etc/letsencrypt/configs/*.conf; do
    letsencrypt --renew --config "$conf" certonly
done
systemctl restart nginx

ownCloud set up.

By default the config file is in config/config.php under /var/www/ownCloud. I had to make a couple changes in there, including adding a domain entry and moving the storage from the SSD to a spinning hard drive.

Docker note: config.php is rewritten by owncloud!!

This is unfortunate because it means that dbhost will be rewritten from a name to an ip number, so if you move mysql to a new ip it will break. To fix it edit config.php and put the name back in. Then config.php will get rewritten AGAIN with an ip but hopefully the correct one. Until the next time you move it... good luck...

Back up and upgrade ownCloud

The running instance of ownCloud will notify you when an upgrade is available. This is an outline of the procedure.

1. Back up the database

cd /green/BACKUPS/bellman_mysql
mysqldump -u root -p owncloud > owncloud.sql

The backup file is currently 26 MB

2. Back up data Attach external drive.

mount /dev/sdd1 /mnt
cd /green
rsync -av owncloud /mnt

The data folder currently is 15 GB. This copy will take an hour or two...

3. Upgrade (before Docker)

Download and unpack the new version

unzip owncloud*zip
cd /var/www/owncloud
cp -p ../owncloud.OLD/config/config.php config
sudo -u www-data php occ upgrade

3. Upgrade (after Docker)

sudo systemctl stop docker-owncloud.service
# edit /lib/systemd/system/docker-owncloud.service
sudo systemctl start docker-owncloud.service
docker exec -u www-data owncloud php occ upgrade

Clients (synchronize files)

This is the "normal" way to use Owncloud: a separate copy of a folder and all its contents is kept on your computer, and when you make a change it's synced with the server. When a change is made on someone else's computer, it's synced to the server and if you share the same folder, the changes then copy down to your computer.

If you BOTH make changes at the SAME time, well, let's not talk about that right now.

There are clients for

  • Mac
  • Linux
  • Android
  • Windows

Debian

The DEB package is missing dependencies. I built one from sources. Much of this page is correct. I got by anyway.

https://doc.owncloud.org/desktop/2.1/building.html#generic-build-instructions

They left out

sudo apt-get install libssl-dev

And they install in /usr/local/bin and lib and don't set up ld.so.conf.d

Once I fixed those problems it started up just fine.

Mac Laptop set up

I set it to sync my own files all the time. I was tempted to sync music too, but that seems like a waste of space for the laptop. Julie's computer just syncs the document space. My GIS laptop syncs everything.

Android set up

The Android client is an "on demand" thing. You can browse and then select files to pull. In the photo gallery you can push photos up to the server. I think I had it set to push photos automatically but as I am usually offline when taking pictures it always failed and then complained.

Wish list

I'd love to have the server download new magazines for me, and then they'd get sync'ed to my laptop and tablet and I'd get notifications.

Whoooooooooo wouldn't it be great if I could use this to manage map data? The server would cache map tiles for the areas I specified, and it would download them when they change upstream. Then ownCloud client would pull them down onto my laptop and/or Android devices. This would facilitate offline map usage without ever having to touch the mapping clients. Whenever my device is online, it would sync map tiles even if the mapping apps were turned off. Then the next time I fire up the map client when I am (for example) hiking or standing on a street corner waiting for a bus, I'd have fresh maps.

Syncing Dropbox to ownCloud -- If I am not using Dropbox on my Android devices, then I need to have a way to access Dropbox files via ownCloud. I can probably write a Python script that will run on the server and monitor the Dropbox folder. Every time it sees a change there it can sync the ownCloud folder contents.

WebDAV clients (using owncloud as a file server)

If you don't want sync or you don't want to sync everything on your server, you could use the Web interface but that is clumsy.

Instead you can set up a WebDAV connection.

WebDAV for Mac

It works exactly as expected; in Finder use Cmd-K and enter the URL, something like https://bellman.wildsong.biz/owncloud/remote.php/webdav and then enter credentials when prompted.

Your owncloud folder will be mounted as a folder and you can access files on the server. It's a bit pokey as you might expect, but it works.

WebDAV for Windows

Windows 7

Built in support does not work so mapping a drive FAILS.

I cannot get it to store a self-signed certificate so I cannot use https connections with Windows. Preparation. You have to add a key to the Windows registry. Good luck. Ask for help. Refer to directions here and look for Windows Vista. https://support.microsoft.com/en-us/kb/841215

Map Network Drive - Windows sucks and this does not work.

  1. Click on the Start menu and select "Computer"
  2. Right click on Computer and select "Map network drive...".
  3. Select a drive letter. I use "T:" for TrailPeople.
  4. For "folder", enter the correct URL, currently this should work https://bellman.wildsong.biz/owncloud/remote.php/webdav

eventually it will be at https://diskstation.trailpeople.net/owncloud/remote.php/webdav

  1. You probably have to check the box "Connect using different credentials". When it asks you for them, you can check

"Remember my credentials" if you want.

Windows 10

tbd