Carlos Spitzer bio photo

Carlos Spitzer

Senior Consultant at Red Hat

Email Twitter Facebook Google+ LinkedIn Github

Index

A few weeks ago I was wondering what additional service I could provide to my family using my Intel NUC D34010WYK in order to centralize cloud storage and avoid using commercial cloud-based solutions: Google Drive, OneDrive, Dropbox… Every one is expensive and I’m not really sure if my personal data could not be analyzed by “men in black”, you know. Also, if I can manage my own cloud service I could provide storage, contact management, online file edition, centralized calendar, platform user management and a lot more storage space available (as many GiB as my USB 3.0 external disk has available). Moreover, all of this for free and using OpenSource technologies.

What do I mean about “OpenSource Infrastructure Cloud Storage” solution? OK, it simple: a piece of OpenSource software that you can install on your computer providing cloud storage management. The software is entirely administred by you, and you are the only responsible for its availability.

What is ownCloud

The best way to know the features of ownCloud 7 is to review the official video-review:


In this post I’m going to explain how to install and configure your ownCloud infrastructure, providing the following services to any user that could want to use your platform (for example, your family): * 10 GiB free space for every user account (expandable if you want). * Centralize contacts and calendar, providing smartphone and cloud integration. * Online “open format” files edition (odt, odp, ods). Remember, all of this for free.

Installation and configuration

### Installing ownCloud 7 I suggest to follow the ownCloud Administration Guide to understand the installation & configuration steps.

I’m going to explain how to install ownCloud on Fedora 20. For other OS you can follow similar steps, but you should refer to official ownCloud Administration Guide.

First, you need to create the repository in order to receive future updates:

cd /etc/yum.repos.d/
wget http://download.opensuse.org/repositories/isv:ownCloud:community/Fedora_20/isv:ownCloud:community.repo

At the time I’m writing this post, ownCloud needs to have SElinux disabled in order to work properly. Please, be aware if you want to preserve your current SElinux activated, you may find some troubles during installation or configuration phase.

Then, install it:

yum install owncloud

Now, we can follow the Installation Wizard to assist us during this phase.

If you access to http:///owncloudyou and press “Advanced” dropdown menu, you may see the followin screen:

If you want to use HTTPs, please, follow this post in order to create SSL certificates and configure the Apache service to use them.

First you can customize the local Data forlder to use. I suggest you to keep this unchanged and then redirect local user folders to your external hard disk or NAS using symbolic links. Then, you must select the administrator username and password and which database provided you prefer to use: * Internal SQLite database: for small/medium purposes. * MySQL local or external database: for medium/high workloads. If you choose this one, you must provide the mySQL connection settings in order to finish the installation.

In my case, I use SQLite because I’m going to serve to no more than 5-6 users and my Intel NUC is not a powerfull machine to run MySQL, PLEX media server and bit-torrent client at the same time :-)

Once you’ve entered all settings, press “Finish Setup” (ownCloud will set up your cloud according to the given settings). When its finished, it will log you in as administrative user and present the “Welcome to ownCloud” screen.

If you found the following error message when you access the Welcome page: “Your web server is not yet properly setup to allow files synchronization because the WebDAV interface seems to be broken. Please double check the installation guides.” Please refer to this link in order to fix it.

### Configuring and managing ownCloud Now you have installed the ownCloud platform, you should refer to the Configuration and Management documentation in order to learn and understand how many options are available for you and your purposes.

Here, I’m going to explain how to create one “test” account, give it 10 GiB of disk quota and how to centralize contacts and calendar management using a smartphone (Android, iOS, etc..).

User management

A user represents an account of the ownCloud installation. The main fields for this entity are the following: * Login name (Username): This is the unique ID of a ownCloud user (e.g. test, jon.doe). * Full Name: This is the name that is used all over the user interface to identify the user i.e. when sharing data or sending mails. If no display name is set, it defaults to the login name. * Password: This is the password the user uses to login to ownCloud. * Groups: This is a list of security groups the user is assigned to. By default the user is not member of any user group. * Group Admin: This is a list of security groups the user has administration privileges for. By default the user is not registered as group admin for any user group. * Quota: This is the maximum disk space that may be used by the user. If the user reaches this limit he/she is not able to upload or sync further data. The storage quota is specified in the format Number Unit (e.g. 100 B (byte), 50 KB (kilobyte), 20 MB (megabyte), 5 GB (gigabyte)). If no unit is given, the number is interpreted as bytes.

To create a new user account, follow these steps: 1. Enter the new user’s Login Name and its initial Password in the appropriate fields (I create a ‘test’ user). 2. (Optional) Select the Groups to which you want to assign the new user. 3. Click Create. 4. (Optional) Edit additional user settings. To set other user settings, such as setting a display name or limiting the user’s storage, please, refer to this link. Created users will have the storage specified on Default Storage setting on the same page (located right-below the screen, on the gear icon). You can change it, for example to 10 GiB.

Use your external storage to store data (instead of internal hard disk)

It’s recommended to use external storage (usb 3.0 or NAS) to store your data (and provide more available space for your users). To use it, the easiest way is to create a symbolic link to point to the user folder located on your external disk or NAS.

But first, after create the new user ‘test’, if you open a shell session on your machine, you will see a new folder has been created:

[root@home]# ll /var/www/html/owncloud/data
...
-rwxrwx--- 1 apache apache         0 Aug 11 23:08 index.html
-rwxrwx--- 1 apache apache 114422784 Aug 24 11:50 owncloud.db
-rw-r----- 1 apache apache   3715824 Aug 23 17:56 owncloud.log
lrwxrwxrwx 1 apache apache        29 Aug 12 12:40 test

If we want to redirect the user data to an external storage (usb hard disk or NAS), first we must sync all info stored in the owncloud user folder to the new one on external storage (in my case, mounted on /media/MEDIA/ownCloud directory):

[root@home]# mkdir /media/MEDIA/ownCloud/test
[root@home]# rsync -Pav /var/www/html/owncloud/data/test/* /media/MEDIA/ownCloud/test/
[root@home]# rm -rf /var/www/html/owncloud/data/test

And then, we can create a symbolic link to this new folder:

[root@home]# ln -s /media/MEDIA/ownCloud/test /var/www/html/owncloud/data/test
[root@home]# ll /var/www/html/owncloud/data
total 115384
-rwxrwx--- 1 apache apache         0 Aug 11 23:08 index.html
-rwxrwx--- 1 apache apache 114422784 Aug 24 11:50 owncloud.db
-rw-r----- 1 apache apache   3715824 Aug 23 17:56 owncloud.log
lrwxrwxrwx 1 apache apache        29 Aug 12 12:40 test -> /media/MEDIA/ownCloud/test

Now, you have the current user data stored using the external device.

Smartphone and PC client integration or “How to explain to your users how to manage their ownCloud services”

This is the hardest part of the job: explain to your users (family and potential non-technical users) how to manage this new account and services. OwnCloud has a very good start-point guide that you can share with your users. Instead of write how to do it, it’s better to follow the latest updated ownCloud guide. I wish you luck!! XD

Backup your platform

In order to make a daily/weekly/monthly backup of your ownCloud configuration, you can use the following script and configure cron to call it using your desired frequency:

[root@home:~]# ll backup.sh 
-rwx------ 1 root root 1095 Aug 13 19:12 backup.sh
#!/bin/bash
 
PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
cd /media/MEDIA/ownCloud/lestrade84/files/Proyectos/OpenShift
 
# Backup ownCloud site
cd /media/MEDIA/ownCloud/admin/files/ownCloud
tar -zcvf ./owncloud-dirbkp_$(date +"%Y%m%d").tar.gz  /var/www/html/owncloud
cp owncloud-dirbkp_$(date +"%Y%m%d").tar.gz /root/backup/ownCloud/
sqlite3 /var/www/html/owncloud/data/owncloud.db .dump > ./owncloud-sqlbkp_$(date +"%Y%m%d").bak
cp owncloud-sqlbkp_$(date +"%Y%m%d").bak /root/backup/ownCloud/

I call it every sunday using cron, so I save a weekly-backup copy for configuration and database dump on my external device and intel-nuc’s local directory /root/backup. Also, I use Fedora 20 ownCloud client integration, so every week the client automatically download the latest backup file generated (so I have 3 different copies of this data for security and availability reasons).

You can use the scheme which best fit your purposes.