backintime icon indicating copy to clipboard operation
backintime copied to clipboard

callback / mount not called when the profile changed

Open buhtz opened this issue 8 years ago • 7 comments

While starting BIT and opening a the main profile the callback script is called as excpected (event-ID 5 & 7).

But when changing the profile something is wrong. Callback script is called with event-ID 8 for the main profile before switching to the new selected profile.

But then no event is called for the new profile. (e.g. mount).

The debug output (german)

Back In Time
Version: 1.2.0~alpha0

DEBUG: [common/backintime.py:669 getConfig] config file: /home/user/.config/backintime/config
DEBUG: [common/backintime.py:670 getConfig] share path: /home/user/.local/share/backintime
DEBUG: [common/backintime.py:672 getConfig] profiles: 1=Hauptprofil, 3=share, 4=MyAppData, 5=ARCHIV, 6=Musik, 7=Dokumente
DEBUG: [common/pluginmanager.py:90 PluginManager.load] Register plugin path /usr/share/backintime/plugins
DEBUG: [common/pluginmanager.py:106 PluginManager.load] Add plugin usercallbackplugin.py
DEBUG: [common/pluginmanager.py:106 PluginManager.load] Add plugin qt4plugin.py
DEBUG: [common/pluginmanager.py:106 PluginManager.load] Add plugin userscriptsplugin.py
DEBUG: [common/pluginmanager.py:106 PluginManager.load] Add plugin notifyplugin.py
DEBUG: [plugins/usercallbackplugin.py:41 callback] args: ('5',) profileID: None
DEBUG: [plugins/usercallbackplugin.py:47 UserCallbackPlugin.callback] Call user-callback: /home/user/.config/backintime/user-callback 1 Hauptprofil 5
INFO: [plugins/usercallbackplugin.py:59 UserCallbackPlugin.callback] user-callback returned 'INFO    : ['/home/user/.config/backintime/user-callback', '1', 'Hauptprofil', '5']'
DEBUG: [common/tools.py:817 keyringSupported] Found appropriate keyring 'keyring.backends.SecretService'
DEBUG: [common/mount.py:73 Mount.__init__] pw-cache is not running
DEBUG: [common/mount.py:82 Mount.__init__] Call command: /usr/bin/backintime pw-cache start
DEBUG: [common/mount.py:117 mount] mode: None check: True kwargs: {}  # mein Debug-Code in erster Zeile von "def mount()"
DEBUG: [plugins/usercallbackplugin.py:41 callback] args: ('7',) profileID: 1
DEBUG: [plugins/usercallbackplugin.py:47 UserCallbackPlugin.callback] Call user-callback: /home/user/.config/backintime/user-callback 1 Hauptprofil 7
INFO: [plugins/usercallbackplugin.py:59 UserCallbackPlugin.callback] user-callback returned 'INFO    : ['/home/user/.config/backintime/user-callback', '1', 'Hauptprofil', '7']
INFO    : mount /mnt/Sparky/Backup'
DEBUG: [common/tools.py:1212 readCrontab] Read 12 lines from users crontab
DEBUG: [common/config.py:1495 Config.removeOldCrontab] Clearing system Back In Time entries
DEBUG: [common/config.py:1528 Config.cronLine] Profile: Hauptprofil | Automatic backup: Alle 6 Stunden
DEBUG: [common/config.py:1528 Config.cronLine] Profile: share | Automatic backup: Wiederholend (anacron)
DEBUG: [common/config.py:1528 Config.cronLine] Profile: MyAppData | Automatic backup: Wiederholend (anacron)
DEBUG: [common/config.py:1528 Config.cronLine] Profile: ARCHIV | Automatic backup: Wiederholend (anacron)
DEBUG: [common/config.py:1528 Config.cronLine] Profile: Musik | Automatic backup: Wiederholend (anacron)
DEBUG: [common/config.py:1528 Config.cronLine] Profile: Dokumente | Automatic backup: Wiederholend (anacron)
DEBUG: [common/config.py:1479 setupCron] Crontab didn't change. Skip writing.

### switching to profile "Musik"

user@TONNE:~/share/work/bit/backintime/common$ 
user@TONNE:~/share/work/bit/backintime/common$ DEBUG: [common/tools.py:817 keyringSupported] Found appropriate keyring 'keyring.backends.SecretService'
DEBUG: [common/mount.py:73 Mount.__init__] pw-cache is not running
DEBUG: [common/mount.py:82 Mount.__init__] Call command: /usr/bin/backintime pw-cache start
DEBUG: [plugins/usercallbackplugin.py:41 callback] args: ('8',) profileID: 1
DEBUG: [plugins/usercallbackplugin.py:47 UserCallbackPlugin.callback] Call user-callback: /home/user/.config/backintime/user-callback 1 Hauptprofil 8
INFO: [plugins/usercallbackplugin.py:59 UserCallbackPlugin.callback] user-callback returned 'INFO    : ['/home/user/.config/backintime/user-callback', '1', 'Hauptprofil', '8']
INFO    : umount -l /mnt/Sparky/Backup'
DEBUG: [common/configfile.py:531 Config.setCurrentProfile] change current profile: 6=Musik

buhtz avatar Mar 26 '17 20:03 buhtz

backintime v1.3.2 In confirm this bug, it's easy to trap it with this

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
    echo "$3" + "$2" + `date` > /tmp/txt1

[...]

  8) ## Unmount the drives ##
     #  Here you should place unmount scripts for the drive you mounted in 7)
        echo "$3" + "$2" + `date` > /tmp/txt2

Then run watch 'more /tmp/txt1 and watch 'more /tmp/txt2 in 2 different terminals.

=> 7) ## Mount drives ## block is NOT triggered at each change of profile. Only at BiT GUI start.

Saroumane avatar Jun 05 '22 19:06 Saroumane

I have fixed the bug (or at least make this part of the GUI working again).

The unit tests are OK (make test and make test-v) except that I have skipped the ssh related tests...

To apply the fix use the attached patch file in the root folder of the git repo (which exactly comments out one line: https://github.com/bit-team/backintime/blob/e22c7f253fa048fab9119f4cbea34c0fa8d1aba6/common/mount.py#L270

patch -p0 -i bug_724_patch.txt

Note: This patch also works with version 1.2.1 which is the version packaged for Ubuntu 20.04 (the current Git version as of today is 1.3.2). You just have to manually modify the file of the installed version of BiT (for Ubuntu: in /usr/share/backintime/common/mount.py

bug_724_patch.txt

Tests & feed-back for my patch are welcome (esp. unwanted side-effects or other bugs that may be introduced unintentionally!)

Edit: Note to self: Remount should keep the existing mount instead of umount+mount. Improve the fix...

aryoda avatar Aug 22 '22 11:08 aryoda

Very funny to see this was my own bug report 5 years ago.

Awesome and thank you very much. We appreciate it.

Please note that currently a new maintainer/developer team is forming around the current maintainer @Germar . It will take some time to establish new team structures and process and to make the project up and running again.

But I will have a look into the problem and your fix. And then maybe @emtiu can merge it then.

buhtz avatar Aug 22 '22 12:08 buhtz

Oh, hi there, just found this while sorting Issues :) Would you open a Pull Request, @aryoda? That gives us a better place to test and discuss the solution.

emtiu avatar Sep 12 '22 09:09 emtiu

I will do so after I have tested it more deeply.

Currently the patch does does umount+mount to "remount" (as hotfix), instead it should do nothing, if the mount is still valid. For this I have to understand the hash arguments flying arround to recognize existing mounts...

aryoda avatar Sep 12 '22 09:09 aryoda

Note to self: The patch does not fix the related #977 I think (because the report says that the an unmount occurs after a manual backup in the GUI causing the snapshot list to be empty).

  • An umount should not be called when
    • backintime-qt quits and a manually started backup is still running.
    • or a manually started backup via CLI is still running (very tricky, because the backup must unmount at the end but only if backintime-qt does not access the mount anymore. How to sync this?)
  • Also a real "remount" must be done (= do not unmount + mount if the mounted folder is the same).

In other words: Only the last single backintime CLI or GUI instance shall unmount when quitting. This requires to understand the BiT lock and flock files better...

aryoda avatar Sep 25 '22 00:09 aryoda