Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

callback / mount not called when the profile changed #724

Open
buhtz opened this issue Mar 26, 2017 · 7 comments
Open

callback / mount not called when the profile changed #724

buhtz opened this issue Mar 26, 2017 · 7 comments

Comments

@buhtz
Copy link
Member

buhtz commented Mar 26, 2017

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
@Germar Germar added this to the 1.2.0 milestone Mar 27, 2017
@Germar Germar modified the milestones: 1.2.0, 1.3.0 Nov 10, 2018
@Saroumane
Copy link

Saroumane commented Jun 5, 2022

backintime v1.3.2
I 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.

@aryoda
Copy link
Contributor

aryoda commented Aug 22, 2022

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:

return 'local'

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...

@buhtz
Copy link
Member Author

buhtz commented Aug 22, 2022

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.

@emtiu
Copy link
Member

emtiu commented Sep 12, 2022

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.

@aryoda
Copy link
Contributor

aryoda commented Sep 12, 2022

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
Copy link
Contributor

aryoda commented Sep 25, 2022

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...

@buhtz
Copy link
Member Author

buhtz commented May 4, 2024

Moin,
I am not into all details here. What are the next steps? Can you offer this modification as a Pull Request? Then others can more easily test it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants