De-Googling: Migrating from Google Photos to Nextcloud
Over time I'm slowly migrating my digital life away from Google products and towards open-source, privacy friendly, or self-hosted versions.
- ✅
Google Analytics - ✅
Google Search - ☑️ Google Photos
- ☑️ Gmail
- ☑️ Android Phone
Today I'm going to be switching from Google Photos to open-source, self-hosted content platform Nextcloud.
Nextcloud is essentially a self-hosted content management system with some collaboration and syncing stuff built in. I shopped around a bit for alternatives, and this seemed like: a) the easiest to set up, and b) the one with the richest ecosystem of plugins and documentation.
My priorities are simply to have a secure web interface where I can see all my photos and videos, and automatically sync photos from my phone. It looks like Nextcloud is capable of both those things!
All together it took me about a day to set-up and replace my Google Photos functionality with Nextcloud. Here's what I did...
Hosting
Nextcloud is self-hosted - this offers obvious privacy improvements over Google Photos - I'm now 100% in control of my data.
To host the system I'm using DigitalOcean, and it seems to work fine on their cheapest droplet with Ubuntu 20.04 (which costs $5). The droplet only gives me 25GB of disk so I'm using external storage to host all the photos and other files. In DigitalOcean this is called Spaces and works the same way as Amazon's S3.
There were a few specific install changes that I needed to make in order to get Nextcloud to work with Spaces, which I'll talk about in the next step.
Installing Nextcloud
I installed with Snap, which is Ubuntu's new container-like app platform. It installs Nextcloud and all it's dependencies in one hit, and stores the relevant config all in one place. This is my first experience with it and it was pretty smooth.
There are already a few great tutorials already out there on how to do this, but here's a quick run down.
First install the snap:
$ sudo snap install nextcloud
Once installed, Nextcloud exposes a bunch of cli commands. So we can use these to set a few options. First the default admin user. This is what we'll use to login to the web interface later.
$ sudo nextcloud.manual-install james password
I wanted to use a custom domain, so we have to set that:
$ sudo nextcloud.occ config:system:set trusted_domains 1 --value=cloud.squarecat.io
And it will even set up a lets-encrypt certificate for you:
$ sudo nextcloud.enable-https lets-encrypt
Finally to get the Nextcloud install to communicate with my DigitalOcean Space. There's no simple command to set this so I had to edit the config file manually.
I updated the objectstore
property to specify the details of my DigitalOcean Space:
/var/snap/nextcloud/current/nextcloud/config/config.php
'objectstore' =>
array (
'class' => '\\OC\\Files\\ObjectStore\\S3',
'arguments' =>
array (
'bucket' => '<SPACES_NAME>',
'key' => '<SPACES_KEY>',
'secret' => '<SPACES_SECRET_KEY>',
'hostname' => 'sgp1.digitaloceanspaces.com',
'region' => 'sgp1',
'port' => 443,
'use_ssl' => true,
'use_path_style' => true,
),
),
After saving that file and restarting the snap everything seemed to be working.
$ sudo snap restart nextcloud
After setting up my custom domain to point to the correct droplet I was presented with the Nextcloud login page!
Photo Sync
This was easy, I installed the Nextcloud app on my Android phone, pointed it at the correct domain, told it what to backup and it was done!
It's been uploading photos for a couple of weeks and seems to work fine. Though I've found a few issues. For example, if I crop or edit an image on my phone a few hours after taking it, then the original photo has already been uploaded and when it tries to upload the edited one the file name throws a conflict. But the app lets you resolve that without much trouble.
The searching obviously isn't as good as the Google equivalent, but I think they're working to improve that.
After making sure the backup was working okay I disabled the auto-sync in Google Photos so that it would stop uploading and I was 100% switched to Nextcloud.
Maps
There's a feature of Google Photos which plots all your photos on a map. I travel a lot and can never remember what date I was in a place so I find it difficult to find photos when I'm telling a story in a bar. So this map view is really useful for me.
There is a Nextcloud App for this simply called Maps, but so far I've not been able to get it to work. I'll update this if I fix it!
Security
It's important to me that this is all secure & private. Nextcloud is open-source which makes me relatively sure there are no obvious vulnerabilities. I work in devops so can make sure that my servers are all locked down. However, by default the web interface is only secured by username & password, which could be better.
After a short search through the apps I found a basic 2FA plugin, which works with any authenticator app. This makes me feel a little safer about my data.
You can even restrict access to specific IP addresses if you want to beef up security further.
Backups
Although DigitalOcean Spaces have automatic backups, I also like to store my data offsite using a different hosting provider. This means if for some reason DigitalOcean terminated my account (which does happen) or had some sort of catastrophic outage then my photos would still be safe.
So I wrote the following script to make nightly backups of all my photos to a separate service called Backblaze. This runs every midnight with cron. I also back up the Nextcloud database data as well using their cli tool nextcloud.export
.
#!/bin/bash
# export nextcloud data
nextcloud.export
# tar the backup data then delete
tar -zcf "nc-$(date '+%Y-%m-%d').tar.gz" -C /var/snap/nextcloud/common backups
rm -rf /var/snap/nextcloud/common/backups/*
# copy the database info
rclone copy "nc-$(date '+%Y-%m-%d').tar.gz" backblaze:squarecat-nextcloud/db
# sync the images from Spaces to Backblaze
rclone sync space: backblaze:squarecat-nextcloud/images
Is it worth it?
There are a few things missing, and the UI isn't quite so pleasing, but overall I'm happy I've managed to get rid of one more Google product that I was relying on quite heavily. To me it's worth making a few sacrifices for that.
- ✅
Google Analytics - ✅
Google Search - ✅ Google Photos
- ☑️ Gmail
- ☑️ Android Phone
In terms of cost I have the whole setup running on a single DigitalOcean droplet for $5/month, the storage in Spaces costs another $5 for the first 250GB (but if you're already using it then it's practically free to add extra files), and the backups cost a few cents per month. Nextcloud itself is completely free to self-host like this.
In comparison Google was charging me $2/month for 100GB of storage across all their apps. Your miliage may vary of course, though obviously for me this wasn't about the price 👀
I think the next big step for me is to get rid of Gmail once and for all. Follow me on Twitter and I'll let you know when I'm ready to free my emails from Google!