Skip to content

Commit 2c96ae6

Browse files
authored
Add support for Incremental Backups (hestiacp#3960)
Add support for Incremental backups via Restic
1 parent 6159f99 commit 2c96ae6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3387
-24
lines changed

bin/v-add-backup-host

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ port=$6
2525
arch=$(arch)
2626

2727
# Includes
28+
# shellcheck source=/etc/hestiacp/hestia.conf
29+
source /etc/hestiacp/hestia.conf
2830
# shellcheck source=/usr/local/hestia/func/main.sh
2931
source $HESTIA/func/main.sh
3032
# load config file

bin/v-add-backup-host-restic

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
#!/bin/bash
2+
# info: add backup host
3+
# options: TYPE HOST USERNAME PASSWORD [PATH] [PORT]
4+
#
5+
# example: v-add-backup-host sftp backup.acme.com admin p4$$w@Rd
6+
# v-add-backup-host b2 bucketName keyID applicationKey
7+
#
8+
# Add a new remote backup location. Currently SFTP, FTP and Backblaze are supported
9+
10+
#----------------------------------------------------------#
11+
# Variables & Functions #
12+
#----------------------------------------------------------#
13+
14+
# Argument definition
15+
repo=$1
16+
snapshots=$2
17+
daily=$3
18+
weekly=$4
19+
monthly=$5
20+
yearly=$6
21+
22+
# CPU Architecture
23+
arch=$(arch)
24+
25+
# Includes
26+
# shellcheck source=/etc/hestiacp/hestia.conf
27+
source /etc/hestiacp/hestia.conf
28+
# shellcheck source=/usr/local/hestia/func/main.sh
29+
source $HESTIA/func/main.sh
30+
# load config file
31+
source_conf "$HESTIA/conf/hestia.conf"
32+
# Fetch current verison B2 CLI tool
33+
source_conf "$HESTIA/install/upgrade/upgrade.conf"
34+
35+
is_negative_one_or_int() {
36+
if [[ "$1" != '-1' ]]; then
37+
is_int_format_valid "$1" "$2"
38+
fi
39+
}
40+
41+
#----------------------------------------------------------#
42+
# Verifications #
43+
#----------------------------------------------------------#
44+
45+
check_args '6' "$#" "REPO SNAPSHOTS DAILY WEEKLY MONTHLY YEARLY"
46+
47+
format_no_quotes $repo 'Repository host'
48+
is_negative_one_or_int $snapshots 'Snapshots'
49+
is_negative_one_or_int $daily 'Daily snapshots'
50+
is_negative_one_or_int $weekly 'Weekly snapshots'
51+
is_negative_one_or_int $monthly 'Monthly snapshots'
52+
is_negative_one_or_int $yearly 'Yearly snapshots'
53+
54+
# Perform verification if read-only mode is enabled
55+
check_hestia_demo_mode
56+
57+
#----------------------------------------------------------#
58+
# Action #
59+
#----------------------------------------------------------#
60+
61+
# Check if Restic is allready installed if not install it ...
62+
if ! which /usr/bin/restic > /dev/null 2>&1; then
63+
apt install restic
64+
fi
65+
# Update restic to last release
66+
restic self-update > /dev/null 2>&1
67+
68+
echo "REPO='$repo'" > /usr/local/hestia/conf/restic.conf
69+
echo "SNAPSHOTS='$snapshots'" >> /usr/local/hestia/conf/restic.conf
70+
echo "KEEP_DAILY='$daily'" >> /usr/local/hestia/conf/restic.conf
71+
echo "KEEP_WEEKLY='$weekly'" >> /usr/local/hestia/conf/restic.conf
72+
echo "KEEP_MONTHLY='$monthly'" >> /usr/local/hestia/conf/restic.conf
73+
echo "KEEP_YEARLY='$yearly'" >> /usr/local/hestia/conf/restic.conf
74+
75+
$BIN/v-change-sys-config-value 'BACKUP_INCREMENTAL' 'yes'
76+
77+
#----------------------------------------------------------#
78+
# Hestia #
79+
#----------------------------------------------------------#
80+
81+
# Logging
82+
log_event "$OK" "$ARGUMENTS"
83+
84+
exit

bin/v-add-user-package

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ is_package_consistent() {
7171
is_int_format_valid "$BANDWIDTH" 'BANDWIDTH'
7272
fi
7373
is_int_format_valid "$BACKUPS" 'BACKUPS'
74+
is_boolean_format_valid "$BACKUPS_INCREMENTAL" 'BACKUP_INCREMENTAL'
7475
if [ -n "$WEB_TEMPLATE" ]; then
7576
is_web_template_valid "$WEB_TEMPLATE"
7677
fi
@@ -151,6 +152,7 @@ NS='$NS'
151152
SHELL='$SHELL'
152153
SHELL_JAIL_ENABLED='$SHELL_JAIL_ENABLED'
153154
BACKUPS='$BACKUPS'
155+
BACKUPS_INCREMENTAL='$BACKUP_INCREMENTAL'
154156
TIME='$time'
155157
DATE='$date'
156158
" > "$HESTIA/data/packages/$package.pkg"

0 commit comments

Comments
 (0)