🍇
RaspberryPI Home Server
  • 🏠Home
  • 🛠️Settings
    • ⚙️GPIO and Fan Controller
    • ⚡Power Optimization
    • 🛡️Uncomplicated Firewall
    • 📃Manual Steps
  • 🔮Services
    • 🔀Traefik Proxy
    • 🏡Homer
    • 🖥️Monitoring
    • 🎞️Jellyfin
    • 💽Databases
    • ☁️Nextcloud
      • 💪Upgrade
      • ♻️Restore
      • 📦Backup
    • 🥧Pihole
    • 🛳️Portainer
    • 🗃️File Browser
    • 🔎SearXNG
    • 📥Torrent Stack
      • 🥷Wireguard
      • 🎥Radarr
      • 📽️Sonarr
      • 🧥Jackett
  • 👉Tip and Tricks
    • 🔵Bluetooth
    • 💽Disk Configurations
Powered by GitBook
On this page
  • Initialize restic repos
  • Set maintenance mode ON
  • Run restic backups
  • Unset maintenance mode

Was this helpful?

  1. Services
  2. Nextcloud

Backup

Nextcloud back with restic

PreviousRestoreNextPihole

Last updated 2 years ago

Was this helpful?

Below steps are not tested fully.

These are basic steps to perform backup nextcloud with restic

From nextcloud , there 2 location that need to be backed up. There are

  • Nextcloud data directory

  • Postgresql database dumps For these, we need to create 2 restic repos to maintain.

Initialize restic repos

NEXTCLOUD_DATA_RESTIC_REPO="/media/disk1/nextcloud_data_restic_repo"
NEXTCLOUD_PG_RESTIC_REPO="/media/disk1/nextcloud_pg_restic_repo"
BACKUP_DIR="/media/disk2/nextcloud"
RESTIC_PASSWORD_FILE="/home/veerendra/pass.txt"
  • NEXTCLOUD_DATA_RESTIC_REPO is the restic repo for nextcloud data directory backup

  • NEXTCLOUD_PG_RESTIC_REPO is the restic repo for postgresql database dumps backup

  • BACKUP_DIR backup directory of nextcloud data

  • RESTIC_PASSWORD_FILE Restic repo password file for both repos

Init the repos

$ restic -r $NEXTCLOUD_DATA_RESTIC_REPO init
$ restic -r $NEXTCLOUD_PG_RESTIC_REPO init

Set maintenance mode ON

$ docker exec -it -u www-data nextcloud php occ maintenance:mode --on

Run restic backups

Backup nextcloud data

$ restic -r $NEXTCLOUD_DATA_RESTIC_REPO \
      -p $RESTIC_PASSWORD_FILE \
      --json \
      backup $BACKUP_DIR

Backup postgresql database dump

$ docker exec postgres \
      bash -c 'pg_dump -c -U `cat $POSTGRES_USER_FILE` `cat $POSTGRES_DB_FILE`' | \
      restic backup --stdin --json \
      -r $NEXTCLOUD_PG_RESTIC_REPO \
      -p /home/veerendra/pass.txt \
      --stdin-filename db_postgres_nextcloud.sql

Unset maintenance mode

$ docker exec -it -u www-data nextcloud php occ maintenance:mode --off

This automates above steps with metrics

🔮
☁️
📦
docs
shell script