Cloud Backup — OPNsense documentation (2024)

  • »
  • System »
  • Configuration »
  • Cloud Backup

Google Drive and Nextcloud

Google Drive is a digital file storage and management service by theinformation technology company Google. Amongst other features, likecollaborative editing of documents, spreadsheets, and presentations, itallows signed up users with an account to store and share files in thedigital cloud.

Nextcloud is also an online storage but in contrast to Google Driveit is intended for self hosting. You can download it freely from theirwebsite and install it on your webserver.

The OPNsense configuration can be stored as a backup file in XML format,to your PC on an USB stick or remotely in the digital Google Drivecloud.

Free online storage

Because Google officially offers a free storage of 15 GB and nearlyunlimited traffic, a remote backup of an OPNsense configuration file isfree of charge, the only thing you need is an account at Google(Google Drive Signup) .

Easy API

An application programming interfaces (API) for Google Drive wasreleased in 2013. This API empowers third-party developers to easilywrite apps for Google Drive.

Nextcloud is using WebDAV which works without a special libraryso data can be sent directly to the server without a special clientlibrary (for example, a file upload is just a HTTP PUT call).

Remote backup

In OPNsense1 you can backup your configuration directly andautomatically to Google Drive and Nextcloud, using the new backupfeature. Every backup to Google Drive will be encrypted with the samealgorithm used in the manual backup so it’s quite easy to restore to a newinstalled machine.

After set-up, the backup feature will run a first backup of the OPNsenseconfiguration file. Then, if the configuration is subsequently changed, a new backup will be run once per day early in the morning.

You may consider specifying additional Cronjobs when more frequent remote backups or remote backups at different times of the day would be required.

Setup Google API usage

The instructions below apply to a standard Google account. Some of the settings appear slightly differently for Google Workspace (formerly G Suite) accounts.

A standard Google account can be created here.

1. Set up a Google Project

First you need to set up a project in the Google developer console.

  • Go to the developer console and log into your Google account.

  • On the “Manage resources” page that appears, click on the + CREATE PROJECT button:

    Cloud Backup — OPNsense documentation (2)

  • On the next page enter a name for your project, for example “OPNsense Backups”. You may leave it as the default name (“My Project #####”), as it does not really matter. Then click on the CREATE button:

    Cloud Backup — OPNsense documentation (3)

  • Now enable the Google Drive API for your project. In the search bar at the top of the page, search for “Google Drive API” and click on the corresponding search result:

    Cloud Backup — OPNsense documentation (4)

  • On the next page, make sure your project name (for example “OPNsense Backups”) is displayed at the top of the page - if not, select it in the dropdown. Then click the ENABLE button:

    Cloud Backup — OPNsense documentation (5)

  • Now create a service account for your project. In the search bar at the top of the page, search for “service accounts” and click on the corresponding search result:

    Cloud Backup — OPNsense documentation (6)

  • Click on the + CREATE SERVICE ACCOUNT button:

    Cloud Backup — OPNsense documentation (7)

  • Enter an account name (for example “OPNsense”) and a description (for example “OPNsense Backups service account”), then click the CREATE button:

    Cloud Backup — OPNsense documentation (8)

  • Click the CONTINUE button on the next page:

    Cloud Backup — OPNsense documentation (9)

  • Then click the DONE button:

    Cloud Backup — OPNsense documentation (10)

  • On the next page, take a note of the email address for your new service account - you will need it later. Then click on the three vertical dots under the Actions heading for your service account, then click on Create key:

    Cloud Backup — OPNsense documentation (11)

  • In the popup screen, select P12, and click CREATE:

    Cloud Backup — OPNsense documentation (12)

  • You will be prompted to download the key. Do so, and then click CLOSE in the popup screen.

  • Now click on the newly created Service Account:

    Cloud Backup — OPNsense documentation (13)

  • Write down the Unique ID of the Service Account. This ID will be your Client-ID in the OPNSense Google Drive backup:

    Cloud Backup — OPNsense documentation (14)

2. Set up a Google Drive folder

The next thing is to create a folder in Google Drive and share it to the service account you’ve just created.

  • Go to https://drive.google.com. You should be still logged into your Google account, otherwise log in.

  • Click + New (upper left of the screen) and select Folder in the dropdown menu that appears:

    Cloud Backup — OPNsense documentation (15)

  • Enter a name for the folder (for example “OPNsense Backups”, it doesn’t really matter) and then click the CREATE button:

    Cloud Backup — OPNsense documentation (16)

  • Right-click the newly created folder and click Share in the dropdown menu that appears:

    Cloud Backup — OPNsense documentation (17)

  • Paste the email address for the service account into the “Add people and groups” box, press Enter and then click the Send button that appears:

    Cloud Backup — OPNsense documentation (18)

  • Now double-click on the folder to open it and take a note of the folder ID from the URL - you will need it later. The folder ID is the last piece of the URL after /folders/:

    Cloud Backup — OPNsense documentation (19)

3. Set up the account in OPNsense

Now put it all together in OPNsense.

  • Log into your OPNsense firewall and go to the backup feature. It is located at System ‣ Configuration ‣ Backups.

  • Scroll down to the Google Drive section and and enter the following values:

    Enable

    checked

    Email Address

    enter the Unique ID number of the service account you created

    P12 key

    click the Choose file button and select the P12 key you saved earlier to upload it

    Folder ID

    paste the Google Drive folder ID that you copied earlier

    Prefix hostname to backupfile

    checked or unchecked as desired (useful if you have multiple OPNsenses)

    Backup Count

    enter the number of backups you want to keep

    Password

    choose a strong password to encrypt the backup

    Confirm

    re-enter the strong password

  • Then click the Setup/Test Google Drive button. OPNsense will automatically save and test your settings and you will receive either an error (connectivity issues) or a message saying “Backup successful” with a list of files currently in the backup.

The moment the feature is enabled, it will do a daily compare of the last file in backup and the current configuration and create a new backup when something has changed.

Setup Nextcloud API usage

1. Step Create a new user

Click on the user icon top right and click “Users”.In the new page, enter an username and a password into the boxes and clickcreate to create a new user.

2. Step Create an Access Token

Close the modal dialog and remove the default files.Then open the Settings menu (also in the menu top right).Switch to security and generate a App password.

Cloud Backup — OPNsense documentation (20)

Copy and store the generated password.

3. Step Connect OPNsense with Nextcloud

Cloud Backup — OPNsense documentation (21)

Scroll to the Nextcloud Section in System ‣ Config ‣ Backup and enter thefollowing values:

Enable

checked

URL

Base URL of your Nextcloud installation like https://cloud.example.com

User

your choosen username

Password

paste your app password from step 2

Backup Directory

a name consisting of alphanumeric characters (keep default)

4. Step Verify the Configuration Upload

When everything worked, you will see the newly created directory after savingthe settings:

Cloud Backup — OPNsense documentation (22)

If you open it, you will see at lease a single backed up configuration file:

Cloud Backup — OPNsense documentation (23)

References

Notes

1 As of OPNsense version 15.1.8.2 (25 March 2015)

Cloud Backup — OPNsense  documentation (2024)

References

Top Articles
Latest Posts
Article information

Author: Otha Schamberger

Last Updated:

Views: 6020

Rating: 4.4 / 5 (75 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Otha Schamberger

Birthday: 1999-08-15

Address: Suite 490 606 Hammes Ferry, Carterhaven, IL 62290

Phone: +8557035444877

Job: Forward IT Agent

Hobby: Fishing, Flying, Jewelry making, Digital arts, Sand art, Parkour, tabletop games

Introduction: My name is Otha Schamberger, I am a vast, good, healthy, cheerful, energetic, gorgeous, magnificent person who loves writing and wants to share my knowledge and understanding with you.