File tree Expand file tree Collapse file tree 7 files changed +40
-8
lines changed
Expand file tree Collapse file tree 7 files changed +40
-8
lines changed Original file line number Diff line number Diff line change 6565# Update restic to last release
6666restic self-update > /dev/null 2>&1
6767
68+ # Check if $repo starts with a slash
69+ if [[ $repo == " /" * ]]; then
70+ if [ ! -d " $repo " ]; then
71+ check_result $E_NOTEXIST " Directory '$repo ' does not exist"
72+ fi
73+ fi
74+
75+ # Check if $repo starts with rclone
76+ if [[ $repo == " rclone:" * ]]; then
77+ # remove rclone: from $repo
78+ repo=$( echo " $repo " | sed ' s/rclone://' )
79+ # check if rclone is working
80+ if ! rclone lsd " $repo " > /dev/null 2>&1 ; then
81+ check_result $E_NOTEXIST " Rclone repository '$repo ' does not exist"
82+ fi
83+ fi
84+
6885echo " REPO='$repo '" > /usr/local/hestia/conf/restic.conf
6986echo " SNAPSHOTS='$snapshots '" >> /usr/local/hestia/conf/restic.conf
7087echo " KEEP_DAILY='$daily '" >> /usr/local/hestia/conf/restic.conf
Original file line number Diff line number Diff line change @@ -71,7 +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 '
74+ is_boolean_format_valid " $BACKUPS_INCREMENTAL " ' BACKUPS_INCREMENTAL '
7575 if [ -n " $WEB_TEMPLATE " ]; then
7676 is_web_template_valid " $WEB_TEMPLATE "
7777 fi
@@ -150,7 +150,7 @@ BANDWIDTH='$BANDWIDTH'
150150NS='$NS '
151151SHELL='$SHELL '
152152BACKUPS='$BACKUPS '
153- BACKUPS_INCREMENTAL='$BACKUP_INCREMENTAL '
153+ BACKUPS_INCREMENTAL='$BACKUPS_INCREMENTAL '
154154TIME='$time '
155155DATE='$date '
156156" > " $HESTIA /data/packages/$package .pkg"
Original file line number Diff line number Diff line change @@ -46,10 +46,6 @@ check_hestia_demo_mode
4646# Get current time
4747start_time=$( date ' +%s' )
4848
49- # Set notification email and subject
50- subj=" $user → backup failed"
51- email=$( grep CONTACT " $HESTIA /data/users/admin/user.conf" | cut -f 2 -d \' )
52-
5349tmpdir=" /home/$user /backup/"
5450
5551# We delete the backup dir first make sure all old database has been cleared
Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ check_hestia_demo_mode
4444# Action #
4545# ----------------------------------------------------------#
4646
47+ # Set notification email and subject
48+ subj=" $user → backup failed"
49+ email=$( grep CONTACT " $HESTIA /data/users/$ROOT_USER /user.conf" | cut -f 2 -d \' )
50+
4751source_conf $HESTIA /conf/restic.conf
4852
4953if [ ! -f " $USER_DATA /restic.conf" ]; then
@@ -54,11 +58,24 @@ if [ ! -f "$USER_DATA/restic.conf" ]; then
5458 if [ $? -ne 0 ]; then
5559 check_result $E_CONNECT " Unable to create restic repo"
5660 fi
61+ else
62+ # Check if repo exists and is accessible with restic key
63+ restic --repo " $REPO$user " --password-file $USER_DATA /restic.conf --json dump $snapshot /home/$user /backup/backup.conf > /home/$user /tmp/backup.conf
64+ if [ $? -ne 0 ]; then
65+ # Send an email
66+ echo " Unable to open restic backup. It might not exists or key is incorrect" | $SENDMAIL -s " $subj " " $email " " yes"
67+ check_result $E_CONNECT " Unable to access restic repo"
68+ fi
69+ rm /home/$user /tmp/backup.conf
5770fi
5871
5972# create backup of the user.conf an database
6073$BIN /v-backup-user-config $user
6174restic --repo " $REPO$user " --password-file $USER_DATA /restic.conf backup /home/$user
75+ if [ $? -ne 0 ]; then
76+ echo " Unable to create the backup" | $SENDMAIL -s " $subj " " $email " " yes"
77+ check_result $E_BACKUP " Unable to backup user"
78+ fi
6279
6380if [[ -n " $SNAPSHOTS " && " $SNAPSHOTS " -ge 0 ]]; then
6481 restic_prune=" $restic_prune --keep-last $SNAPSHOTS "
Original file line number Diff line number Diff line change @@ -78,6 +78,7 @@ json_list() {
7878 "U_DATABASES": "' $U_DATABASES ' ",
7979 "U_CRON_JOBS": "' $U_CRON_JOBS ' ",
8080 "U_BACKUPS": "' $U_BACKUPS ' ",
81+ "BACKUPS_INCREMENTAL": "' $BACKUPS_INCREMENTAL ' ",
8182 "LANGUAGE": "' $LANGUAGE ' ",
8283 "THEME": "' $THEME ' ",
8384 "NOTIFICATIONS": "' $NOTIFICATIONS ' ",
Original file line number Diff line number Diff line change 1515 $ data = array_reverse ($ data , true );
1616 }
1717 unset($ output );
18-
1918 render_page ($ user , $ TAB , "list_backup " );
2019} else {
2120 exec (
Original file line number Diff line number Diff line change 66 <a href="/schedule/backup/?token=<?= $ _SESSION ["token " ] ?> " class="button button-secondary"><i class="fas fa-circle-plus icon-green"></i><?= _ ("Create Backup " ) ?> </a>
77 <a href="/list/backup/exclusions/" class="button button-secondary"><i class="fas fa-folder-minus icon-orange"></i><?= _ ("Backup Exclusions " ) ?> </a>
88 <?php } ?>
9- <a href="/list/backup/incremental/" class="button button-secondary"><i class="fas fa-vault icon-blue"></i><?= _ ("Incremental Backups " ) ?> </a>
9+ <?php if ($ panel [$ user_plain ]['BACKUPS_INCREMENTAL ' ] === 'yes ' ) { ?>
10+ <a href="/list/backup/incremental/" class="button button-secondary"><i class="fas fa-vault icon-blue"></i><?= _ ("Incremental Backups " ) ?> </a>
11+ <?php } ?>
1012 </div>
1113 <div class="toolbar-right">
1214 <?php if ($ read_only !== "true " ) { ?>
You can’t perform that action at this time.
0 commit comments