backintime icon indicating copy to clipboard operation
backintime copied to clipboard

(German) notify-send notifications only shown after backintime GUI was launched

Open grhansolo opened this issue 9 years ago • 7 comments

Hallo Germar,

zur Datensicherung nutze ich Euer prima Tool „Back in Time“.

Mit Hilfe des von Euch zur Verfügung gestellten Call-Back-Scriptes lasse ich mir einen Status bezogen auf die Datensicherung auf dem Mint Cinnamon Desktop ausgeben. Für diese Statusausgabe wird ja der Befehl „notifiy-send“ verwendet.

Ich habe Back in Time so konfiguriert, dass es täglich automatisch über Anacron eine Sicherung durchführt. Die Sicherung funktioniert unabhängig davon, ob "Back in Time" als Programm gestartet wurde oder nicht.

Das Call-Back-Skript funktioniert allerdings leider nur dann, wenn ich „Back in Time“ vorher händisch gestartet habe.

Beispiel 1:

  • Back in Time händisch starten
  • Sicherung wird zum definierten Zeitpunkt automatisch ausgeführt
  • Call-Back-Skript gibt Meldungen auf dem Bildschirm aus

Beispiel 2:

  • Back in Time wird NICHT händisch gestartet
  • Sicherung funktioniert trotzdem (wird wohl irgendwie im Hintergrund ausgeführt, weil "Back in Time" ja nicht händisch gestartet wurde)
  • Call-Back-Skript gibt KEINE Meldungen auf dem Bildschirm aus

Meine Frage:

Wie kann ich erreichen, dass das Call-Back-Skript auch dann gestartet wird und Meldungen zum Status ausgibt, wenn „Back in Time“ nicht vorher händisch gestartet wurde?

grhansolo avatar Oct 07 '16 07:10 grhansolo

Ich bin grade im Urlaub und kann deswegen nur raten. Aber ich würde als erstes darauf tippen, dass du den Back in Time Dienst aus dem Autostart deaktiviert hast. Der speichert nämlich deine Session ID und ander wichtige env-Variablen in eine Datei, damit sie später von cron-Jobs gelesen werden können. Cron-Jobs werden ohne diese Variablen gestartet und sind erstmal nicht in der Lage, mit deinem x-Server zu kommunizieren

Germar avatar Oct 07 '16 12:10 Germar

Hallo Germar,

vielen Dank für Deine Rückmeldung und sorry für die Störung im Urlaub.

Ich bin Linux Neuling, deshalb die Frage ob du mir sagen kannst wie ich den Dienst wieder aktivieren kann. Weiß aktuell nicht wie ich herausfinden kann ob der Dienst wirklich deaktiviert ist.

Wenn der Dienst wirklich deaktiviert ist, dann dürfte doch die Sicherung selbst auch nicht funktionieren, die Sicherung selbst funktioniert allerdings einwandfrei auch dann wenn BiT nicht händisch gestartet wurde. Nur das Call-Back-Script macht Probleme, das funktioniert nur dann, wenn ich BiT gestartet habe.

Viele Grüße

Robert

Am 07.10.2016 um 14:36 schrieb Germar Reitze:

Ich bin grade im Urlaub und kann deswegen nur raten. Aber ich würde als erstes darauf tippen, dass du den Back in Time Dienst aus dem Autostart deaktiviert hast. Der speichert nämlich deine Session ID und ander wichtige env-Variablen in eine Datei, damit sie später von cron-Jobs gelesen werden können. Cron-Jobs werden ohne diese Variablen gestartet und sind erstmal nicht in der Lage, mit deinem x-Server zu kommunizieren

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bit-team/backintime/issues/643#issuecomment-252241097, or mute the thread https://github.com/notifications/unsubscribe-auth/AVoAVkT3PNY-nzlciHtCFpXm2vMjVPc_ks5qxjzHgaJpZM4KQv3U.

grhansolo avatar Oct 07 '16 12:10 grhansolo

Ich hab das jetzt mal nachgestellt. Wenn Backintime Password Cache in den Startprogrammen deaktiviert ist, dann werden bei mir auch keine Benachrichtigungen angezeigt.

Daher öffne bitte Systemeinstellungen > Einstellungen > Startprogramme und aktiviere Backintime Password Cache

Germar avatar Oct 10 '16 22:10 Germar

Hallo Germar,

"Backintime Password Cache" war bereits aktiviert (siehe hierzu nachfolgender Screenshot).

Die "notify-send" Benachrichtigungen werden leider trotzdem nicht angezeigt, wenn "Back in Time" nicht gestartet ist.

Das Call-Back-Script wird anscheinend doch (anders als erst vermutet) bei nicht gestartetem "Back in Time" ausgeführt. Das weiß ich, weil das Verschicken der Statusmails über das Call-Back-Script (in Verbindung mit meinem Postfix) einwandfrei funktioniert. Nur das "notify-send" funktioniert AUSSCHLIEßLICH bei gestartetem "Back in Time". Anbei mal mein Call-Back-Script, vielleicht siehst du dann meinen Fehler, ich habe das Call-Back-Script nämlich ein bisschen verändert.

Viele Grüße und vielen Dank.

Robert

Am 11.10.2016 um 00:27 schrieb Germar Reitze:

Ich hab das jetzt mal nachgestellt. Wenn |Backintime Password Cache| in den Startprogrammen deaktiviert ist, dann werden bei mir auch keine Benachrichtigungen angezeigt.

Daher öffne bitte |Systemeinstellungen > Einstellungen > Startprogramme| und aktiviere |Backintime Password Cache|

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bit-team/backintime/issues/643#issuecomment-252762796, or mute the thread https://github.com/notifications/unsubscribe-auth/AVoAVq7TLv8dXFYGbRnLlEHvvOrnbBfvks5qyrvBgaJpZM4KQv3U.

#!/bin/bash

# Example script for user-callback

# user-callback is a script called by backintime (http://backintime.le-web.org)

# before, during and after a backup.

# Copyright (c) 2014 Fabrizio Marana

# This program 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 3 of the License, or (at your option) any later version.

# This program 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 AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR

# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER

# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN

# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

# See the GNU General Public License for more details.

# You DID NOT receive a copy of the GNU General Public License along with this

# program as the license is bigger then this program.

# Therefore, see http://www.gnu.org/licenses/ for more details.

# Note:

# To allow the notify-send "expire-time" parameter to work,

# follow http://www.webupd8.org/2014/04/configurable-notification-bubbles-for.html

# To allow mail to be sent, the "mailutils" package must be installed and

# configured and there must be a MTA (Mail Transport Agent) e.g. "postfix"

# or "exim4" installed and configured:

# sudo apt-get install mailutils

# sudo apt-get install postfix

# https://www.google.com/search?q=linux+configure+mailutils

# Version 0.2 DD 2014/11/08 Change as much fixed text to variables to allow

# others to modify more easily

# Polish code to make it more readable

# TO DO:  Use rsync instead of cpio

### Init

# You need to configure this before using this script

declare szBackInTimeEMailAddress="[email protected]"   #if empty, no mail will be sent on error
declare szBackupVolume=""             #if empty, no finalising will be performed

# BackInTime passes arguments on the command line.  Name them for clarity.

declare iBackInTimeProfileID="$1"
declare szBackInTimeProfileName="$2"
declare iBackInTimeStatus="$3"
declare iBackInTimeSnapshotID="$4"
declare szBackInTimeSnapshotName="$5"

### main

case $iBackInTimeStatus in
  1)  ## Backup Starting ##
      # Here you should put commands that you need JUST before the backup begins, E.g.:
        # stop daemons/services, ...
      notify-send --urgency=critical --icon=face-plain "BackInTime" \
        "Starting backup '${iBackInTimeProfileID}:${szBackInTimeProfileName}'..."
  ;;
  2)  ## Backup Finished ##
      notify-send --urgency=critical --icon=face-laugh "BackInTime" \
        "Finished backup '${iBackInTimeProfileID}:${szBackInTimeProfileName}' completely!"
      mail -s "Backup abgeschlossen" [email protected] < ~/.local/share/backintime/takesnapshot_.log
      # Here you should put the commands that you need after the backup ends, E.g.:
      # (Probably the reverse of the 1) section)
        # allow the user to try again later, ...
  ;;
  3)  ## Backup Finishing ##
      notify-send --urgency=critical --icon=face-cool --expire-time=4000 "BackInTime" \
        "Finishing backup '${iBackInTimeProfileID}:${szBackInTimeProfileName}'\nfor snapshot '${iBackInTimeSnapshotID}:${szBackInTimeSnapshotName}'..."
      # Here you should put the commands that you need to do just before the backup finishes:
      #   Copying extra files,
      #   writing to logs, ...
  ;;
  4) # An error occurred: $iBackInTimeSnapshotID contains the error number
    declare -r iBackInTimeError=$iBackInTimeSnapshotID
    declare szBackInTimeErrorMessage="BackInTime Error: "
    declare szBackInTimeExtendedErrorMessage=""
    # We're notifying the user on-screen and emailing the log file
    # using the mailutils package regardless of the kind of error
    case $iBackInTimeError in
      1)  ## Application not configured ##
          szBackInTimeErrorMessage=$szBackInTimeErrorMessage" Application not configured!"
          ;;
      2)  ## Application already Running ##
          szBackInTimeErrorMessage=$szBackInTimeErrorMessage" BackInTime is already running!"
          szBackInTimeExtendedErrorMessage="\n\nPlease ensure you don't have an automatic backup and a manual backup both running at once."
          ;;
      3)  ## No snapshot Directory ##
          szBackInTimeErrorMessage=$szBackInTimeErrorMessage" BackInTime can’t find the snapshots directory!"
          szBackInTimeExtendedErrorMessage="\n\n(Is it on a removable drive which was detached/unmounted in error?)"
          ;;
      4)  ## Snapshot already exixsts ##
          szBackInTimeErrorMessage=$szBackInTimeErrorMessage" A snapshot for 'now' already exists!"
          ;;
    esac # Error
    notify-send --urgency=critical --icon=face-angry "BackInTime Error" "$szBackInTimeErrorMessage$szBackInTimeExtendedErrorMessage"
    # only send mail if the e-mail address is not empty
    if [ -n "$szBackInTimeEMailAddress" ] &&  \
       [ "x$(which mail)" != "x" ] && \
       [ -x $(which mail) ]; then
      mail --subject="$szBackInTimeErrorMessage$(date +%Y-%m-%d)" --to "$szBackInTimeEMailAddress"<~/.local/share/backintime/takesnapshot_.log
    fi
  ;;
  5)  ## backintime-qt4 (GUI) started ##
      #  Here you can put things that need to be done when launching the GUI
  ;;
  6)  ## backintime-qt4 (GUI) closed ##
      #  Here you can put things that need to be done when closing the GUI
  ;;
  7) ## Mount drives ##
     #  Here you should place custom mount commands which will be called everytime
     #  the GUI or command line tool is started or the profile is switched in GUI
  ;;
  8) ## Unmount the drives ##
     #  Here you should place unmount scripts for the drive you mounted in 7)
  ;;
esac #Status

grhansolo avatar Oct 11 '16 08:10 grhansolo

Hallo Germar,

ich denke ich habe das Problem weiter eingrenzen können. Stelle ich den Zeitplan von Anacron auf "Alle 5 Minuten" um, so funktionieren die "notify-send" Meldungen tadellos, auch dann, wenn BiT nicht gestartet ist.

Bei der Nutzung von Anacron werden mir die notify-send Meldungen hingegen nicht auf dem Cinnamon Desktop angezeigt. Ich sollte hier dazu sagen, dass ich den Rechner nachts immer aus schalte. Morgens, wenn ich den Rechner starte, legt Anacron demnach mit der Sicherung los. Die Meldungen vom Call-Back-Skript werden allerdings nicht auf dem Cinnamon Desktop ausgegeben.

Viele Grüße

Robert

grhansolo avatar Oct 11 '16 13:10 grhansolo

Okay, ich hab das jetzt reproduzieren können, hab den Fehler aber noch nicht gefunden...

Germar avatar Oct 11 '16 21:10 Germar

English summary: notify-send notifications from the user-callback script are only shown in the (Cinnamon) desktop environment after the backintime GUI has been open once since the system booted. If the GUI hasn't been loaded, the notifications are not sent.

This is closely related to #770, possible even a duplicate.

emtiu avatar Sep 12 '22 09:09 emtiu