Skip to content

Commit c09dfd9

Browse files
committed
nc-snapshot-auto: read datadir location during execution
Signed-off-by: nachoparker <nacho@ownyourbits.com>
1 parent f71c8c8 commit c09dfd9

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

bin/ncp/BACKUPS/nc-snapshot-auto.sh

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/bash
22

33
#
4-
# NextCloudPi scheduled datadir BTRFS snapshots
4+
# NextCloudPi scheduled datadir BTRFS snapshots
55
#
66
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
77
# GPL licensed (see end of file) * Use at your own risk!
@@ -17,32 +17,31 @@ install()
1717
}
1818

1919
configure()
20-
{
21-
[[ $ACTIVE != "yes" ]] && {
20+
{
21+
[[ "$ACTIVE" != "yes" ]] && {
2222
rm -f /etc/cron.hourly/btrfs-snp
2323
echo "automatic snapshots disabled"
2424
return 0
2525
}
2626

27-
local DATADIR MOUNTPOINT
28-
DATADIR=$( sudo -u www-data php /var/www/nextcloud/occ config:system:get datadirectory ) || {
29-
echo -e "Error reading data directory. Is NextCloud running and configured?";
30-
return 1;
31-
}
32-
33-
# file system check
34-
MOUNTPOINT="$( stat -c "%m" "$DATADIR" )" || return 1
35-
[[ "$( stat -fc%T "$MOUNTPOINT" )" != "btrfs" ]] && {
36-
echo "$MOUNTPOINT is not in a BTRFS filesystem"
37-
return 1
38-
}
39-
4027
cat > /etc/cron.hourly/btrfs-snp <<EOF
4128
#!/bin/bash
42-
/usr/local/bin/btrfs-snp $MOUNTPOINT hourly 24 3600 ../ncp-snapshots
43-
/usr/local/bin/btrfs-snp $MOUNTPOINT daily 7 86400 ../ncp-snapshots
44-
/usr/local/bin/btrfs-snp $MOUNTPOINT weekly 4 604800 ../ncp-snapshots
45-
/usr/local/bin/btrfs-snp $MOUNTPOINT monthly 12 2592000 ../ncp-snapshots
29+
DATADIR=\$(ncc config:system:get datadirectory) || {
30+
echo -e "Error reading data directory. Is NextCloud running and configured?";
31+
exit 1;
32+
}
33+
34+
# file system check
35+
MOUNTPOINT="\$(stat -c "%m" "\$DATADIR")" || return 1
36+
[[ "\$( stat -fc%T "\$MOUNTPOINT" )" != "btrfs" ]] && {
37+
echo "\$MOUNTPOINT is not in a BTRFS filesystem"
38+
exit 1
39+
}
40+
41+
/usr/local/bin/btrfs-snp \$MOUNTPOINT hourly 24 3600 ../ncp-snapshots
42+
/usr/local/bin/btrfs-snp \$MOUNTPOINT daily 7 86400 ../ncp-snapshots
43+
/usr/local/bin/btrfs-snp \$MOUNTPOINT weekly 4 604800 ../ncp-snapshots
44+
/usr/local/bin/btrfs-snp \$MOUNTPOINT monthly 12 2592000 ../ncp-snapshots
4645
EOF
4746
chmod 755 /etc/cron.hourly/btrfs-snp
4847
echo "automatic snapshots enabled"

changelog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11

2-
[v1.22.1](https://github.com/nextcloud/nextcloudpi/commit/e68d616) (2020-03-03) samba: option to apply only to a NC group (#1048)
2+
[v1.22.3](https://github.com/nextcloud/nextcloudpi/commit/0e81bc1) (2020-03-02) nc-snapshot-auto: read datadir location during execution
3+
4+
[v1.22.2 ](https://github.com/nextcloud/nextcloudpi/commit/75b1a06) (2020-03-02) nc-maintenance: add is_active
5+
6+
[v1.22.1](https://github.com/nextcloud/nextcloudpi/commit/49de98b) (2020-03-03) samba: option to apply only to a NC group (#1048)
37

48
[v1.22.0 ](https://github.com/nextcloud/nextcloudpi/commit/9304c86) (2020-03-03) Add nc-trusted-proxies (#1094)
59

0 commit comments

Comments
 (0)