Nextcloud Backblaze



NextCloud's object storage support seems to rely on Amazon S3's MultipartUpload which doesn't have an exact equivalent in BackBlaze B2. It isn't a Minio issue because uploading objects to B2 through the Minio web interface or using s3cmd does work. These cookies are necessary for the website to function and cannot be switched off in our systems. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms. Definitive Guide to using Minio as NextCloud Primary Storage Minio is an on-premises object storage server that can be deployed as a Minio cluster (with local storage) or as a gateway to other object storage services with their own API such as Backblaze B2, Azure Blob Storage, and Google Cloud Storage.

“How To Backup Nextcloud” was originally written on 03 July 2019, but has been updated on 19 June 2020.

I recently wrote a guide on how to setup your own Nextcloud server; it’s a great way of ensuring your personal data is kept private. However, it’s also important to backup Nextcloud too.

Nextcloud

Isn’t Nextcloud My Backup?

No it isn’t. Nextcloud is not a backup solution, it’s a way of syncing your data, but it’s not a backup. Think about it, if you delete a file from computer A, that deletion will immediately be synced everywhere via Nextcloud. There are protections in place, such as the trash bin and version control, but Nextcloud is not a backup solution.

Since building my own server I have come up with a pretty decent way of backing up my data that follows the 3-2-1 principle of backing data up.

At least 3 copies of your data, on 2 different storage media, 1 of which needs to be off-site.

— The 3-2-1 backup rule

Requirements

In order to effectively backup Nextcloud, there are a few pieces of hardware and software involved. There is an initial cost to the hardware, but it isn’t significant.

To backup Nextcloud you will need:

  1. An Ubuntu based server running the Nextcloud Snap
  2. A USB hard drive that is at least double the size of the data you’re backing up (I’d recommend getting the biggest you can afford)
  3. Duplicati backup software installed on your Nextcloud server
  4. A Backblaze B2 account
  5. Around 30-60 minutes to set it all up

At this point I will assume that you have connected and mounted your USB hard drive to the server. If you haven’t done that yet, take a look at my guide on how to mount a partition in Ubuntu.

Note: this process is designed around the Nextcloud Snap installation, not the manual installation.

Overview

Following this post, you will be able to do the following:

  1. Automatically backup your entire Nextcloud instance (including your database) every day
  2. Create a log file so you can see if the backup worked
  3. Sync the backup to B2 cloud storage (it will be encrypted before transmission)
  4. Delete old backups so your hard drive doesn’t fill up
  5. Receive email alerts once the backup completes

User Setup

I would reccomend using a dedicated user for backing up. This will allow us to keep the backup routine separate from the normal user account you use, making the setup more secure. Adobe photoshop cs2 mac os x free download.

In this guide, I will be using ncbackup as the user account. You can use whatever username you feel is appropriate. Let’s start by creating the user and the directories we will need to store our backups.

Now we have the directories setup, let’s create the script that will run our backups. In this example, I’m using nano, but feel free to use any text editor you like. To learn more about nano, click here.

We’re using the usr/sbin directory because it is used for system-wide binaries that require elevated privileges. You can store your script wherever you like, but usr/sbin is good practice.

Backup Nextcloud

Populate the file with the following, ensuring you change the username and path to whatever the appropriate values are for your setup.

Now we need to make our backup script executable:

A lot of the commands in our script will require sudo access, but we don’t want to give full sudo access to our ncbackup user, as it doesn’t need elevated rights globally. However, we do want to be able to run the backup script with sudo rights, and we want to do it without requiring a password.

To accomplish this, we need to use visudo. We can configure visudo to allow the ncbackup user to run the backup script as sudo, without a password. Crucially, the ncbackup user will not be able to run anything else as sudo.

Enabling sudo access for the backup script introduces another potential security risk. The ncbackup user can run the backup script as sudo without a password. So a threat actor could potentially edit the script and run any command as sudo without a password.

Bad times.

However, we saved the script in /usr/sbin, which means the ncbackup user will not be able to edit the ncbackup.sh script. By doing so, we have prevented the system from becoming insecure.

As an extra layer of security, we will stop the ncbackup user from being able to login to the server at all:

If at a later date you need to be able to login using the ncbackup user, you can revert change this by running the following command:

Schedule Backups

Now have the backup script setup, we need to schedule the backup to run automatically; for this, we will use Cron.

Run the following command to enter the Cron settings for the ncbackup user:

Once you’re in crontab, you need to add the following lines to the bottom of the file:

The settings above will run the backup script at 02:00am every day. You can change this to whatever value you like, but I would recommend running the backup every day.

The first value represents minutes, then hours, then days etc. So if you wanted to run the backup at 03:30am, your Crontab entry would look something like this:

Now Wait…

That’s most of the setup complete at this point. The next thing to do is to wait 24 hours for your backup to complete automatically (or you could run the script manually yourself).

Once the script has run, you should see a tar.gz file within your backup folder with a name that corresponds to the date the backup ran:

Within the Logs folder, you should also see a <date>.txt file that corresponds to the backup. You can open this to see how your backup went:

With the echo statements we put in the script, you can see at what point in the backup things failed, if they do in fact fail.

Note: there are masses of improvements that can be added to this script, but this satisfies my needs. If you do add improvements, please let me know and I’ll post an update.

Setup Duplicati

You now have a single layer of backups for Nextcloud. However, if you want to abide by the 3-2-1 rule of backups (which I highly recommend), then we now need to use Duplicati to add additional layers to our backup routine.

To install Duplicati, go to this link and right click ‘copy link location‘ on the Ubuntu DEB. Then amend the commands below as appropriate.

We now need to enable the Systemd service for Duplicati so it runs automatically on boot:

By default the Duplicati service will only listen on localhost, so if you try to access the IP of the server from another device, you won’t get the Duplcati webGUI.

To fix this, edit the DAEMON_OPTS option within the Duplicati config to the following:

Restart Duplicati so the config changes take affect:

Nextcloud Backblaze

You should now be able to access the Duplicati web interface by going to http://server-ip:8200. You will be asked to set a password for Duplicati when you first login, make sure this is a strong one!

Security Note: My server is hosted at home, and I don’t expose port 8200 to the internet. If your server is not at home, then I would strongly suggest you configure something like IP Tables, or Digital Ocean firewall, to restrict access to port 8200.

Configure Duplicati Backups

Now its time to configure our backups in Duplicati. We will configure 2 backup routines – 1 to USB and another to Backblaze B2 for off-site.

Let’s do the USB backup first. Within the Duplicati webGUI, click on the Add Backup button to the left of the screen.

This is a very straightforward process where you choose the destination (our USB drive), the source (the output from our backup script) and the schedule.

When creating your backup routines in Duplicati, always ensure you encrypt your backups and use a strong passphrase.

Also, always make sure your Duplicati backups run at different times to your other backups. Personally, I go for the following setup:

Nextcloud backblaze
  • 02:00 – Local Nextcloud backup script runs via Cron
  • 03:00 – Duplicati backs up to USB
  • 04:00 – Duplicati backs up to Backblaze B2

I always leave the Backblaze backup to run last, as it then has up to 22 hrs to complete the upload before the next backup starts, so they shouldn’t interfere with one another.

Off-Site Backups

When it comes to configuring your Backblaze backups, change the destination from Local to B2 Cloud Storage. You will need your B2 bucket information and application keys from to complete the config.

Once you have entered your Backblaze Bucket information, click Test Connection to make sure Duplicati can write to your B2 bucket correctly.

Important note: You will need to add payment information to your Backblaze account before backing up, otherwise your backups will fail.

To give you an idea of what Backblaze costs, I’m currently backing up around 150GB of data to my Buckets, and I’m charged less than $1/month.

Personally, I only keep 7 days of backups on BackBlaze, as I only have it for disaster recovery, where all my local backups have failed. I don’t need data retention in the cloud, that’s what my USB drive is for.

Duplicati Email Notifications

You can configure email notifications for Duplicati backups, this way you will always know if your backups are working.

To do this, head into the Duplicati WebGUI and click on the Settings option to the left of screen, scroll all the way down to the bottom where it says Default options. Click the option that says Edit as text, the paste the following into the field:

I personally use Amazon SES for this, but you should be able to use any SMTP server.

That’s It!

You’re done. That’s it. Best free invoice software for mac. Finito. You now know how to backup Nextcloud in such a way that it abides by the cardinal 3-2-1 backup rule, and it lets you know when your backups have run.

⚠️ ⚠️ TEST YOUR BACKUPS! ⚠️ ⚠️

Nextcloud backblaze backup

I can’t stress this enough. Once your backups have been running for a few days, make sure you run a test restore (not on your live system) to make sure you can get your data back. After all, there’s no point in having backups if you can’t restore from them!

To restore the backups you have made of Nextcloud into a vanilla Nextcloud snap installation, you need to decompress your backup to /var/snap/nextcloud/common then use the nextcloud.import command to restore it:

Yes, restoring your Nextcloud snap from backup really is that simple!

Conclusion

This is by no means the perfect way to backup Nextcloud, but it does work and it has worked for me for quite some time now. You may have a different/better way of backing up, if you do, please leave comment below, or get in touch with me.

Finally, I’d like to thank my friend Thomas from work, who helped improve my script a little and gave me a couple of ideas to improve to the security.

Thanks, Tom. 🙂

Desktop

Connect to your Nextcloud from Windows, macOS or Linux.

Mobile

Use your Nextcloud on the go with our Android and iOS apps.

Server

Stay in control of your data!
Choose one of the providers or download the Nextcloud server for self hosting.

Read the documentation

Here you can find our manuals:

Need help?

Discuss using, installing or maintaining Nextcloud in our support channels. Data recovery software mac free download.

  • IRC Channel (Webchat)

These consist of users helping each other. Consider helping out others, too!

Browse dozens of free apps and services you could use with your Nextcloud on the Nextcloud app store.

Get Involved

If you want to help out with developing and testing, grab a daily build. Find our GitHub project here and find our issue tracker for the server here.

Latest testing version is 21 RC2

Help test our clients: Android Release Candidate client on Play store and Android Beta client on F-Droid. For iOS, join Testflight for iOS

The archive should be extracted in a folder your web server has access to. Latest stable version: 21.0.1 (Changelog)

Follow the Nextcloud Admin Manuals installation chapter.
If you already run Nextcloud, refer to the upgrade manual.
Need an enterprise solution?

  1. Download the .tar.bz2 or .zip archive.
  2. Check package integrity using MD5 (.tar.bz2 / .zip) or SHA256 (.tar.bz2 / .zip)
  3. Verify the authenticity via PGP (.tar.bz2 /.zip). The Nextcloud GPG key is here.

You can already find server packages included with many distributions or provided by active community members. Find an overview of packages for various distributions as well as Docker and snap images here. Can't find packages you need? Ask your distribution for packages or contribute to creating them!

Looking for older versions or major releases?

Nextcloud Server does not support Microsoft Windows. We recommend using a virtual machine or docker image on Windows Server.

Security note:
To receive information about updates and security issues, we recommend a subscription to our low-traffic newsletter.

Release channels:
We offer Release Channels with production, stable, beta and daily-branches. This gives you the opportunity to choose your balance between stability and features.

The Web Installer is the easiest way to install Nextcloud on a web space. It checks the dependencies, downloads Nextcloud from the official server, unpacks it with the right permissions and the right user account. Finally, you will be redirected to the Nextcloud installer.

  1. Right-click here and save the file to your computer
  2. Upload setup-nextcloud.php to your web space
  3. Point your web browser to setup-nextcloud.php on your webspace
  4. Follow the instructions and configure Nextcloud
  5. Login to your newly created Nextcloud instance!
Backblaze

You can find further instructions in the Nextcloud Admin Manual.

Note that the installer uses the same Nextcloud version as available for the built in updater in Nextcloud. After a major release it can take up to a month before it becomes available through the web installer and the updater. This is done to spread the deployment of new major releases out over time.

Nextcloud Server does not support Microsoft Windows. We recommend using a virtual machine or docker image on Windows Server.

Security note:
To receive information about updates and security issues, we recommend a subscription to our low-traffic newsletter.

Release channels:
We offer Release Channels with production, stable, beta and daily-branches. This gives you the opportunity to choose your balance between stability and features.

You can find further instructions in the Nextcloud Admin Manual.
If you already run Nextcloud, refer to the upgrade manual for moving to new Nextcloud releases.


Continue

Security note:
We recommend a subscription to our low-traffic newsletter for notifications on updates and security issues. Find the '>public Nextcloud GPG key here.

Looking for repositories of previous major releases?

Nextcloud Server does not support Microsoft Windows. We recommend using the Nextcloud Appliance on Windows Server.

Virtual Machine image

The Nextcloud VM is designed to be an easy way for less technical users to get Nextcloud up and running or to test it out. It builds on Ubuntu Linux and makes configuration easy.

Find source here.

If you are looking for a more extensive virtual machine with many scripts to easily set up advanced functionality, get the full-version VM from Hansson IT.

For small businesses, Nextcloud GmbH maintains a free appliance built on the Univention Corporate Server (UCS) with easy graphical setup and web-based administration. It includes user management via LDAP as well as optional online office integration. Get the SME/Enterprise appliance.

Docker image

Several Nextcloud community members maintain a Docker image. It supports a wide range of architectures, releases, various webservers, databases and more.

Find source here.

Snap package

Canonical and the Nextcloud community maintain a Nextcloud Snap, including release channels and quick and easy deployment for easy home use.

Security note:
To receive information about updates and security issues, we recommend a subscription to our low-traffic newsletter.

Release channels:
We offer Release Channels with production, stable, beta and daily-branches. This gives you the opportunity to choose your balance between stability and features.
Most of our Appliances support these release channels or let you fix on specific major versions.

Use the desktop clients to keep your files synchronized between your Nextcloud server and your desktop. Select one or more directories on your local machine and always have access to your latest files wherever you are. Learn more about our clients here.


Mac OS 10.10+ (legacy)

Nextcloud Backblaze


Looking for integration apps like browser add-ins for Passwords, a feedreader and more? Check our app store for integrations!

find here:
documentation
source code

You can already find Nextcloud Desktop client packages included in openSUSE Tumbleweed, Arch Linux and Fedora. You can find Ubuntu/Debian packages in this PPA. Packages for Alpine Linux over here. See the latest state and more packages in this post on our forums. Can't find packages? Ask your distribution or contribute to creating them!

Nextcloud Files is using WebDAV, so you can also try out any other client you want!

Try also our Outlook and Thunderbird integration: Sync your files, calendars, contacts and tasks with Outlook or Mozilla Thunderbird

Nextcloud Backblaze Backup

The Nextcloud mobile apps are available in various app stores. Learn more about our clients here.

Nextcloud Files

The apps allow you to access, sync and upload your data and feature instant upload for photos and videos, upload management and more features.

Find iOS Sources here, Android Sources here anddirect APK download here.

Nextcloud Talk

Find iOS Sources here, Android Sources here.

Looking for mobile apps for Deck, News, Passwords and more? Check our app store!

Nextcloud Backblaze B2

Nextcloud is using open standards like CalDAV, WebDAV and IMAP so many independent third party clients can connect to it.