Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornachoparker <nacho@ownyourbits.com>2019-02-18 04:25:04 +0300
committernachoparker <nacho@ownyourbits.com>2019-02-18 04:25:41 +0300
commit5e1ea773fce0f4accf811495060d0188a169f15c (patch)
tree0a9c2cda77e92af32a91cb4630c9ef5d835d5cdf
parent41a48c97aa09a660f3836c93b43a373ec4f5aab1 (diff)
add nc-restore-snapshotv1.7.0
-rw-r--r--bin/ncp/BACKUPS/nc-restore-snapshot.sh64
-rw-r--r--bin/ncp/BACKUPS/nc-snapshot.sh10
-rw-r--r--bin/ncp/CONFIG/nc-datadir.sh1
-rw-r--r--changelog.md6
-rw-r--r--etc/ncp-config.d/nc-restore-snapshot.cfg17
5 files changed, 90 insertions, 8 deletions
diff --git a/bin/ncp/BACKUPS/nc-restore-snapshot.sh b/bin/ncp/BACKUPS/nc-restore-snapshot.sh
new file mode 100644
index 00000000..efb753e8
--- /dev/null
+++ b/bin/ncp/BACKUPS/nc-restore-snapshot.sh
@@ -0,0 +1,64 @@
+#!/bin/bash
+
+#!/bin/bash
+# Nextcloud restore backup
+#
+# Copyleft 2019 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
+# GPL licensed (see end of file) * Use at your own risk!
+#
+# More at nextcloudpi.com
+#
+
+install() { :; }
+
+configure()
+{
+ [[ -d "$SNAPSHOT" ]] || { echo "$SNAPSHOT doesn't exist"; return 1; }
+
+ local datadir mountpoint
+ datadir=$( ncc config:system:get datadirectory ) || {
+ echo -e "Error reading data directory. Is NextCloud running?";
+ return 1;
+ }
+
+ # file system check
+ mountpoint="$( stat -c "%m" "$datadir" )" || return 1
+ [[ "$( stat -fc%T "$mountpoint" )" != "btrfs" ]] && {
+ echo "$datadir is not in a BTRFS filesystem"
+ return 1
+ }
+
+ # file system check
+ btrfs subvolume show "$SNAPSHOT" &>/dev/null || {
+ echo "$SNAPSHOT is not a BTRFS snapshot"
+ return 1
+ }
+
+ btrfs-snp $mountpoint autobackup 0 0 ../ncp-snapshots || return 1
+
+ ncc maintenance:mode --on
+ btrfs subvolume delete "$datadir" || return 1
+ btrfs subvolume snapshot "$SNAPSHOT" "$datadir"
+ ncc maintenance:mode --off
+ ncp-scan
+
+ echo "snapshot $SNAPSHOT restored"
+}
+
+# License
+#
+# This script is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This script is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this script; if not, write to the
+# Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+# Boston, MA 02111-1307 USA
+
diff --git a/bin/ncp/BACKUPS/nc-snapshot.sh b/bin/ncp/BACKUPS/nc-snapshot.sh
index df3bdfac..19699144 100644
--- a/bin/ncp/BACKUPS/nc-snapshot.sh
+++ b/bin/ncp/BACKUPS/nc-snapshot.sh
@@ -9,8 +9,6 @@
#
-BASEDIR=/var/www
-
install()
{
wget https://raw.githubusercontent.com/nachoparker/btrfs-snp/master/btrfs-snp -O /usr/local/bin/btrfs-snp
@@ -19,11 +17,11 @@ install()
configure()
{
- sudo -u www-data php "$BASEDIR"/nextcloud/occ maintenance:mode --on
+ ncc maintenance:mode --on
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?";
+ DATADIR=$( ncc config:system:get datadirectory ) || {
+ echo -e "Error reading data directory. Is NextCloud running?";
return 1;
}
@@ -36,7 +34,7 @@ configure()
btrfs-snp $MOUNTPOINT manual $LIMIT 0 ../ncp-snapshots
- sudo -u www-data php "$BASEDIR"/nextcloud/occ maintenance:mode --off
+ ncc maintenance:mode --off
}
# License
diff --git a/bin/ncp/CONFIG/nc-datadir.sh b/bin/ncp/CONFIG/nc-datadir.sh
index d2bd86cd..5695e04a 100644
--- a/bin/ncp/CONFIG/nc-datadir.sh
+++ b/bin/ncp/CONFIG/nc-datadir.sh
@@ -91,6 +91,7 @@ configure()
sed -i "s|^opcache.file_cache=.*|opcache.file_cache=$DATADIR/.opcache|" /etc/php/${PHPVER}/mods-available/opcache.ini
# update fail2ban logpath
+ [[ -f /etc/fail2ban/jail.local ]] && \
sed -i "s|logpath =.*nextcloud.log|logpath = $DATADIR/nextcloud.log|" /etc/fail2ban/jail.local
# datadir
diff --git a/changelog.md b/changelog.md
index 0f31977e..bdc674ca 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,7 +1,9 @@
-[v1.6.7](https://github.com/nextcloud/nextcloudpi/commit/3bcccdd) (2019-02-17) nc-backup-auto: notify failures
+[v1.7.0](https://github.com/nextcloud/nextcloudpi/commit/b0a83b0) (2019-02-17) add nc-restore-snapshot
-[v1.6.6](https://github.com/nextcloud/nextcloudpi/commit/743cb24) (2019-02-15) nc-automount: fix NFS delay
+[v1.6.7](https://github.com/nextcloud/nextcloudpi/commit/41a48c9) (2019-02-17) nc-backup-auto: notify failures
+
+[v1.6.6 ](https://github.com/nextcloud/nextcloudpi/commit/743cb24) (2019-02-15) nc-automount: fix NFS delay
[v1.6.5 ](https://github.com/nextcloud/nextcloudpi/commit/c28868d) (2019-02-15) nc-trusted-domains: empty values by default
diff --git a/etc/ncp-config.d/nc-restore-snapshot.cfg b/etc/ncp-config.d/nc-restore-snapshot.cfg
new file mode 100644
index 00000000..49efb8b8
--- /dev/null
+++ b/etc/ncp-config.d/nc-restore-snapshot.cfg
@@ -0,0 +1,17 @@
+{
+ "id": "nc-restore-snapshot",
+ "name": "Nc-restore-snapshot",
+ "title": "nc-restore-snapshot",
+ "description": "Restore data from a BTRFS snapshot",
+ "info": "A snapshot of the current data will be taken",
+ "infotitle": "Restore NextCloud data snapshot",
+ "params": [
+ {
+ "id": "SNAPSHOT",
+ "name": "Snapshot Path",
+ "value": "",
+ "suggest": "/media/USBdrive/ncp-snapshots/daily_XXXX-XX-XX_XXXXXX",
+ "type": "directory"
+ }
+ ]
+}