├── .github └── ISSUE_TEMPLATE │ └── config.yml ├── .gitignore ├── README.md ├── user-callback.apt-backup ├── user-callback.default ├── user-callback.diagnostics ├── user-callback.kill_snapshot ├── user-callback.multiple-scripts ├── user-callback.notify ├── user-callback.sendmail └── user-callback.ssid /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Issues 4 | url: https://github.com/bit-team/backintime/issues/new 5 | about: This redirects you to the Issue section of the main repository "backintime". 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # editor backup 7 | *~ 8 | *.sic 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deprecated 2 | The content and functionality of this repository have been moved into the [bit-team/backintime](https://github.com/bit-team/backintime) repository. Please refer to the directory [`doc/user-callback-examples`](https://github.com/bit-team/backintime/tree/dev/doc/user-callback-examples) there. This repository will be removed in the near future. 3 | 4 | --- 5 | 6 | Introduction 7 | ============ 8 | For further information, see the `backintime `_ repository and its `issue tracker `_. 9 | 10 | user-callback 11 | ============= 12 | 13 | During the backup process, `Back In Time `_ can call a user-callback script at different steps. 14 | This user-callback script is contained in the file ``$XDG_CONFIG_HOME/backintime/user-callback`` 15 | (by default ``$XDG_CONFIG_HOME`` is ``~/.config``). 16 | 17 | - The first argument is the profile id (1=Main Profile, ...). 18 | - The second argument is the profile name. 19 | - The third argument is the reason: 20 | 21 | 1. Backup process begins. 22 | 2. Backup process ends. 23 | 3. A new snapshot was taken. The extra arguments are snapshot ID and snapshot path. 24 | 4. There was an error. The fourth argument is the error code. 25 | 26 | Possible error codes are: 27 | 28 | 1. The application is not configured. 29 | 2. A "take snapshot" process is already running. 30 | 3. Can't find snapshots folder (is it on a removable drive ?). 31 | 4. A snapshot for "now" already exist. 32 | 5. Error while taking a snapshot (introduced Aug. 17, 2023) 33 | 6. New snapshot taken but with errors (introduced Aug. 17, 2023) 34 | 35 | The optional fifth argument just for errors is the error message. 36 | 37 | 5. On (graphical) App start. 38 | 6. On (graphical) App close. 39 | 7. Mount all necessary drives. 40 | 8. Unmount all drives. 41 | 42 | For implementation details see the source code in the file ``pluginmanager.py]`` (https://github.com/bit-team/backintime/blob/dev/common/pluginmanager.py). 43 | 44 | -------------------------------------------------------------------------------- /user-callback.apt-backup: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright (c) 2012-2014 Germar Reitze 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | 18 | # backup selection of apt-get 19 | # Take a look at 20 | # https://github.com/bit-team/backintime/wiki/FAQ#how-to-backup-debian-ubuntu-package-selection 21 | # https://github.com/bit-team/backintime/wiki/FAQ#how-to-restore-debian-ubuntu-package-selection 22 | 23 | profile_id="$1" 24 | profile_name="$2" 25 | reason="$3" 26 | errorcode="$4" 27 | DST="$HOME/.apt-backup" 28 | 29 | case $reason in 30 | 1) #on process begin 31 | mkdir -p $DST 32 | dpkg --get-selections > $DST/package.list 33 | apt-mark showauto > $DST/pkg_auto.list 34 | apt-mark showmanual > $DST/pkg_manual.list 35 | rm -f $DST/sources.list.d/* 36 | cp -aR /etc/apt/sources.list* $DST/ 37 | apt-key exportall > $DST/repo.keys 38 | ;; 39 | esac 40 | -------------------------------------------------------------------------------- /user-callback.default: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2012-2015 Germar Reitze 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | 18 | 19 | #Script should return 0 if everything is alright. Returncode !0 will cancle 20 | #the running snapshot (BIT version >1.1.0). 21 | 22 | profile_id="$1" 23 | profile_name="$2" 24 | reason="$3" 25 | 26 | case $reason in 27 | 1) #Backup process begins 28 | ;; 29 | 2) #Backup process ends 30 | ;; 31 | 3) #A new snapshot was taken 32 | snapshot_id="$4" 33 | snapshot_name="$5" 34 | ;; 35 | 4) #There was an error 36 | errorcode="$4" 37 | case $errorcode in 38 | 1) # ERROR The application is not configured 39 | ;; 40 | 2) # ERROR A 'take snapshot' process is already running 41 | ;; 42 | 3) # ERROR Can't find snapshots folder (is it on a removable drive ?) 43 | ;; 44 | 4) # ERROR A snapshot for 'now' already exist 45 | ;; 46 | 5) # ERROR: Error while taking a snapshot 47 | ;; 48 | 6) # ERROR: New snapshot taken but with errors 49 | ;; 50 | *) # Unknown error number 51 | ;; 52 | esac 53 | ;; 54 | 5) #backintime-qt4 (GUI) started 55 | ;; 56 | 6) #backintime-qt4 (GUI) closed 57 | ;; 58 | 7) #Mount drives 59 | ;; 60 | 8) #Unmount the drives 61 | ;; 62 | esac 63 | -------------------------------------------------------------------------------- /user-callback.diagnostics: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2012-2015 Germar Reitze, modified 2022 by J. Altfeld 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | 18 | 19 | #Script should return 0 if everything is alright. Returncode !0 will cancle 20 | #the running snapshot (BIT version >1.1.0). 21 | 22 | # This script is meant for debugging purposes only (to check when 23 | # and how the backup process is started and snapshots are taken. 24 | # You can also add further checks (eg. check for existing mounts 25 | # or readable paths to diagnose problems with inaccessible mounts). 26 | 27 | profile_id="$1" 28 | profile_name="$2" 29 | reason="$3" 30 | 31 | 32 | printLog() { 33 | # argument $1 contains the log message 34 | echo "$(date +'%Y-%m-%d %H:%M:%S') ($(whoami)/$BASHPID) profile_id=$profile_id: $1" 2>&1 >> ~/backintime_usercallback_diagnostics.log 35 | } 36 | 37 | case $reason in 38 | 1) #Backup process begins 39 | printLog "1 - backup process begins" 40 | ;; 41 | 2) #Backup process ends 42 | printLog "2 - backup process ends" 43 | ;; 44 | 3) #A new snapshot was taken 45 | snapshot_id="$4" 46 | snapshot_name="$5" 47 | printLog "3 - snapshot taken (snapshot_id=$snapshot_id - snapshot_name=$snapshot_name)" 48 | ;; 49 | 4) #There was an error 50 | errorcode="$4" 51 | msg="$5" 52 | case $errorcode in 53 | 1) # ERROR: The application is not configured 54 | printLog "4 - ERROR $errorcode: The application is not configured" 55 | ;; 56 | 2) # ERROR: A 'take snapshot' process is already running 57 | printLog "4 - ERROR $errorcode: A 'take snapshot' process is already running" 58 | ;; 59 | 3) # ERROR: Can't find snapshots folder (is it on a removable drive ?) 60 | printLog "4 - ERROR $errorcode: Can't find snapshots folder (maybe it is on a removable drive)" 61 | ;; 62 | 4) # ERROR: A snapshot for 'now' already exist 63 | printLog "4 - ERROR $errorcode: A snapshot for 'now' already exist" 64 | ;; 65 | 5) # ERROR: Error while taking a snapshot 66 | printLog "4 - ERROR $errorcode: Error while taking a snapshot" 67 | ;; 68 | 6) # ERROR: New snapshot taken but with errors 69 | printLog "4 - ERROR $errorcode: New snapshot taken but with errors (may happen with 'continue on error')" 70 | ;; 71 | *) # Unknown error number 72 | printLog "4 - ERROR $errorcode: Unknown error code!" 73 | ;; 74 | esac 75 | printLog " Error message: $msg" 76 | ;; 77 | 5) #backintime-qt4 (GUI) started 78 | printLog "5 - backintime-qt GUI started" 79 | ;; 80 | 6) #backintime-qt4 (GUI) closed 81 | printLog "6 - backintime-qt GUI closed" 82 | ;; 83 | 7) #Mount drives 84 | printLog "7 - mount drive requested" 85 | # Further diagnostics examples (use "on demand"): 86 | 87 | # Check if a mount point is in the list of mounted devices 88 | # mountPoint="/media//" # insert your mount folder here 89 | # printLog "Mount point status: $(mount | grep '$mountPoint')" # empty if not mounted! 90 | 91 | # Check if a folder does exists and is readable (eg. the snapshot target folder) 92 | # testFolder="/path/to/snapshots" # insert your path to check here 93 | # if [[ -r $testFolder ]]; then 94 | # printLog "Folder exists and can be read..." 95 | # else 96 | # printLog "Folder does not exist or cannot be read (missing permissions?)" 97 | # fi 98 | 99 | ;; 100 | 8) #Unmount the drives 101 | printLog "8 - unmount drive requested" 102 | ;; 103 | *) ## Unknown reason 104 | printLog "Called with invalid reason $reason" 105 | ;; 106 | 107 | esac 108 | -------------------------------------------------------------------------------- /user-callback.kill_snapshot: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2012-2014 Germar Reitze 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | 18 | 19 | # stop creating a new snapshot if conditions are not met. For example if the 20 | # source drive isn't mounted. With version >= 1.1.0 you don't need to kill 21 | # processes any more. Just return a non zero returncode. 22 | 23 | profile_id="$1" 24 | profile_name="$2" 25 | pid=$$ 26 | 27 | function ppid { 28 | cat /proc/$1/status | grep "PPid:" | cut -f2 29 | } 30 | 31 | case $3 in 32 | 1) # Backup process begins 33 | if [ true ]; then ###INSERT YOUR CONDITIONS HERE 34 | kill $(ppid $(ppid $pid)) 35 | fi 36 | ;; 37 | 2) # Backup process ends 38 | ;; 39 | 3) # A new snapshot was taken 40 | ;; 41 | 4) #There was an error 42 | case $4 in 43 | 1) # ERROR The application is not configured 44 | ;; 45 | 2) # ERROR A 'take snapshot' process is already running 46 | ;; 47 | 3) # ERROR Can't find snapshots folder (is it on a removable drive ?) 48 | ;; 49 | 4) # ERROR A snapshot for 'now' already exist 50 | ;; 51 | 5) # ERROR: Error while taking a snapshot 52 | ;; 53 | 6) # ERROR: New snapshot taken but with errors 54 | ;; 55 | *) # Unknown error number 56 | ;; 57 | esac 58 | ;; 59 | esac 60 | -------------------------------------------------------------------------------- /user-callback.multiple-scripts: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2012-2014 Germar Reitze 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | 18 | DIR="user-callback.d" 19 | typeset -i returncode=0 20 | 21 | for callback in $(ls -1 $DIR) 22 | do 23 | if [[ -x ${DIR}/${callback} ]]; then 24 | ${DIR}/${callback} "$@" 25 | returncode+=$? 26 | fi 27 | done 28 | exit $returncode 29 | -------------------------------------------------------------------------------- /user-callback.notify: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Example script for user-callback 4 | # user-callback is a script called by backintime (http://backintime.le-web.org) 5 | # before, during and after a backup. 6 | 7 | # Copyright (c) 2014 Fabrizio Marana 8 | 9 | # This program is free software: you can redistribute it and/or modify it under 10 | # the terms of the GNU General Public License as published by the Free Software 11 | # Foundation, either version 3 of the License, or (at your option) any later version. 12 | # This program is distributed in the hope that it will be useful, but WITHOUT 13 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 14 | # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 15 | # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 16 | # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 17 | # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 18 | # See the GNU General Public License for more details. 19 | # You DID NOT receive a copy of the GNU General Public License along with this 20 | # program as the license is bigger then this program. 21 | # Therefore, see http://www.gnu.org/licenses/ for more details. 22 | 23 | # Note: 24 | # To allow the notify-send "expire-time" parameter to work, 25 | # follow http://www.webupd8.org/2014/04/configurable-notification-bubbles-for.html 26 | # To allow mail to be sent, the "mailutils" package must be installed and 27 | # configured and there must be a MTA (Mail Transport Agent) e.g. "postfix" 28 | # or "exim4" installed and configured: 29 | # sudo apt-get install mailutils 30 | # sudo apt-get install postfix 31 | # https://www.google.com/search?q=linux+configure+mailutils 32 | 33 | # Version 0.2 DD 2014/11/08 Change as much fixed text to variables to allow 34 | # others to modify more easily 35 | # Polish code to make it more readable 36 | # TO DO: Use rsync instead of cpio 37 | 38 | 39 | ### Init ### 40 | # You need to configure this before using this script 41 | declare szBackInTimeEMailAddress="" #if empty, no mail will be sent on error 42 | declare szBackupVolume="" #if empty, no finalising will be performed 43 | 44 | # BackInTime passes arguments on the command line. Name them for clarity. 45 | declare iBackInTimeProfileID="$1" 46 | declare szBackInTimeProfileName="$2" 47 | declare iBackInTimeStatus="$3" 48 | declare iBackInTimeSnapshotID="$4" 49 | declare szBackInTimeSnapshotName="$5" 50 | 51 | ### main ### 52 | case $iBackInTimeStatus in 53 | 1) ## Backup Starting ## 54 | # Here you should put commands that you need JUST before the backup begins, E.g.: 55 | # stop daemons/services, ... 56 | notify-send --urgency=LOW --icon=face-plain "BackInTime" \ 57 | "Starting backup '${iBackInTimeProfileID}:${szBackInTimeProfileName}'..." 58 | ;; 59 | 2) ## Backup Finished ## 60 | notify-send --urgency=NORMAL --icon=face-laugh "BackInTime" \ 61 | "Finished backup '${iBackInTimeProfileID}:${szBackInTimeProfileName}' completely!" 62 | # Optional notification via zenity (uncomment to enable): 63 | # zenity --info --title="BackInTime" --text "BackInTime backup for profile ${iBackInTimeProfileID} (${szBackInTimeProfileName}) completed" & 64 | # Here you should put the commands that you need after the backup ends, E.g.: 65 | # (Probably the reverse of the 1) section) 66 | # allow the user to try again later, ... 67 | ;; 68 | 3) ## Backup Finishing ## 69 | notify-send --urgency=NORMAL --icon=face-cool --expire-time=4000 "BackInTime" \ 70 | "Finishing backup '${iBackInTimeProfileID}:${szBackInTimeProfileName}'\nfor snapshot '${iBackInTimeSnapshotID}:${szBackInTimeSnapshotName}'..." 71 | # Here you should put the commands that you need to do just before the backup finishes: 72 | # Copying extra files, 73 | # writing to logs, ... 74 | ;; 75 | 4) # An error occurred: $iBackInTimeSnapshotID contains the error number 76 | declare -r iBackInTimeError=$iBackInTimeSnapshotID 77 | declare szBackInTimeErrorMessage="BackInTime Error: " 78 | declare szBackInTimeExtendedErrorMessage="" 79 | # We're notifying the user on-screen and emailing the log file 80 | # using the mailutils package regardless of the kind of error 81 | case $iBackInTimeError in 82 | 1) ## Application not configured ## 83 | szBackInTimeErrorMessage=$szBackInTimeErrorMessage" Application not configured!" 84 | ;; 85 | 2) ## Application already Running ## 86 | szBackInTimeErrorMessage=$szBackInTimeErrorMessage" BackInTime is already running!" 87 | szBackInTimeExtendedErrorMessage="\n\nPlease ensure you don't have an automatic backup and a manual backup both running at once." 88 | ;; 89 | 3) ## No snapshot Directory ## 90 | szBackInTimeErrorMessage=$szBackInTimeErrorMessage" BackInTime can’t find the snapshots directory!" 91 | szBackInTimeExtendedErrorMessage="\n\n(Is it on a removable drive which was detached/unmounted in error?)" 92 | ;; 93 | 4) ## Snapshot already exixsts ## 94 | szBackInTimeErrorMessage=$szBackInTimeErrorMessage" A snapshot for 'now' already exists!" 95 | ;; 96 | 5) # ERROR: Error while taking a snapshot 97 | szBackInTimeErrorMessage=$szBackInTimeErrorMessage" Error while taking a snapshot" 98 | ;; 99 | 6) # ERROR: New snapshot taken but with errors 100 | szBackInTimeErrorMessage=$szBackInTimeErrorMessage" New snapshot taken but with errors" 101 | szBackInTimeExtendedErrorMessage="\n\nMay happen with 'continue on error'" 102 | ;; 103 | *) # Unknown error number 104 | szBackInTimeErrorMessage=$szBackInTimeErrorMessage" Unknown error code!" 105 | ;; 106 | esac # Error 107 | notify-send --urgency=CRITICAL --icon=face-angry "BackInTime Error" "$szBackInTimeErrorMessage$szBackInTimeExtendedErrorMessage" 108 | # only send mail if the e-mail address is not empty 109 | if [ -n "$szBackInTimeEMailAddress" ] && \ 110 | [ "x$(which mail)" != "x" ] && \ 111 | [ -x $(which mail) ]; then 112 | cat ~/.local/share/backintime/takesnapshot_.log | mail -s "BackInTime backup for profile ${iBackInTimeProfileID} (${szBackInTimeProfileName}) failed on $(date +%Y-%m-%d_%H-%M-%S) with error $szBackInTimeErrorMessage" $szBackInTimeEMailAddress 113 | fi 114 | # Optional notification via zenity (uncomment to enable): 115 | # zenity --error --title="BackInTime" --text="BackInTime backup for profile ${iBackInTimeProfileID} (${szBackInTimeProfileName}) failed on $(date +%Y-%m-%d_%H-%M-%S) with error $szBackInTimeErrorMessagee" & 116 | ;; 117 | 5) ## backintime-qt4 (GUI) started ## 118 | # Here you can put things that need to be done when launching the GUI 119 | ;; 120 | 6) ## backintime-qt4 (GUI) closed ## 121 | # Here you can put things that need to be done when closing the GUI 122 | ;; 123 | 7) ## Mount drives ## 124 | # Here you should place custom mount commands which will be called everytime 125 | # the GUI or command line tool is started or the profile is switched in GUI 126 | ;; 127 | 8) ## Unmount the drives ## 128 | # Here you should place unmount scripts for the drive you mounted in 7) 129 | ;; 130 | esac #Status 131 | -------------------------------------------------------------------------------- /user-callback.sendmail: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2012-2014 Germar Reitze 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | 18 | 19 | #Script should return 0 if everything is alright. Returncode !0 will cancle 20 | #the running snapshot (BIT version >1.1.0). 21 | 22 | email="foo@bar" 23 | profile_id="$1" 24 | profile_name="$2" 25 | reason="$3" 26 | errorcode="$4" 27 | 28 | function send_mail { 29 | subject="Backintime $profile_name: $1" 30 | shift 31 | echo -e "$(date) \n$@" | mail -s "$subject" $email 32 | } 33 | 34 | function log_id { 35 | if [ $profile_id -gt 1 ]; then 36 | echo $profile_id 37 | else 38 | echo "" 39 | fi 40 | } 41 | 42 | case $reason in 43 | 1) send_mail "Backup process begins" 44 | ;; 45 | 2) send_mail "Backup process ends" "$(cat ~/.local/share/backintime/takesnapshot_$(log_id).log)" 46 | ;; 47 | 3) send_mail "A new snapshot was taken" 48 | ;; 49 | 4) #There was an error 50 | case $errorcode in 51 | 1) send_mail "ERROR" "The application is not configured" 52 | ;; 53 | 2) send_mail "ERROR" "A 'take snapshot' process is already running" 54 | ;; 55 | 3) send_mail "ERROR" "Can't find snapshots folder (is it on a removable drive ?)" 56 | ;; 57 | 4) send_mail "ERROR" "A snapshot for 'now' already exist" 58 | ;; 59 | 5) send_mail "ERROR" "Error while taking a snapshot" 60 | ;; 61 | 6) send_mail "ERROR" "New snapshot taken but with errors" 62 | ;; 63 | *) send_mail "ERROR" "Unknown error number" 64 | ;; 65 | esac 66 | ;; 67 | esac 68 | -------------------------------------------------------------------------------- /user-callback.ssid: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright (c) 2012-2016 Germar Reitze 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License along 15 | # with this program; if not, write to the Free Software Foundation, Inc., 16 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 | 18 | 19 | #This script will check if you're connected to the correct WLAN (based on SSID) 20 | #In this example it will break new snapshots for profile 1 if not in 'HOME_WLAN' 21 | #and for profile 2 if not in 'WLAN_AT_WORK' 22 | 23 | profile_id="$1" 24 | profile_name="$2" 25 | reason="$3" 26 | 27 | check_ssid() { 28 | if [ $(iwconfig 2>/dev/null | grep -c "ESSID:\"$1\"") -eq 0 ]; then 29 | return 1 30 | fi 31 | } 32 | 33 | case $reason in 34 | 1) #Backup process begins 35 | case $profile_id in 36 | 1) check_ssid "HOME_WLAN"; exit $?;; 37 | 2) check_ssid "WLAN_AT_WORK"; exit $?;; 38 | esac 39 | ;; 40 | esac 41 | --------------------------------------------------------------------------------