#!/bin/bash # # NextCloudPi scheduled datadir BTRFS snapshots # # Copyleft 2017 by Ignacio Nunez Hernanz # GPL licensed (see end of file) * Use at your own risk! # # More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/ # ACTIVE_=no DESCRIPTION="Scheduled datadir BTRFS snapshots" install() { wget https://raw.githubusercontent.com/nachoparker/btrfs-snp/master/btrfs-snp -O /usr/local/bin/btrfs-snp chmod +x /usr/local/bin/btrfs-snp } configure() { [[ $ACTIVE_ != "yes" ]] && { rm /etc/cron.hourly/btrfs-snp echo "automatic snapshots disabled" return 0 } local DATADIR MOUNTPOINT DATADIR=$( sudo -u www-data php /var/www/nextcloud/occ config:system:get datadirectory ) || { echo -e "Error reading data directory. Is NextCloud running and configured?"; return 1; } # file system check MOUNTPOINT="$( stat -c "%m" "$DATADIR" )" || return 1 [[ "$( stat -fc%T "$MOUNTPOINT" )" != "btrfs" ]] && { echo "$MOUNTPOINT is not in a BTRFS filesystem" return 1 } cat > /etc/cron.hourly/btrfs-snp <