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

Bug/Feature: "additional options to rsync" not used when removing snapshots #1861

Open
xelvinc opened this issue Sep 4, 2024 · 7 comments
Open
Labels
Bug Discussion decision or consensus needed External depends on others/upstream Feature requests a new feature

Comments

@xelvinc
Copy link

xelvinc commented Sep 4, 2024

Short: Additional rsync options (Expert Options -> Paste additional options to rsync) not used when removing snapshots.

When I want to remove a snapshot, I get the error:

WARNING: Command "rsync -a --delete -s /tmp/tmps8asu05e/ /mnt/databackup/backintime/backintime/gentoo/root/1/20240502-194442-488" returns 22 | [generator] exceeded --max-alloc=1073741824 setting (file=ifuncs.h, line=30)  
rsync error: error allocating core memory buffers (code 22) at util2.c(80) [generator=3.3.0]  
ERROR: Last rsync command failed with return code "22". See previous WARNING message in the logs for details.

According to the rsync man page (I'm using version 3.3.0), the default value for --max-alloc (default is 1g) can be overridden with the --max-alloc=SIZE option.

But when I set this option under Expert Options -> Paste additional options to rsync -> --max-alloc=5g, this option is only passed to the command line when taking a new snapshot. Not when removing a snapshot.
Looking in snapshots.py, the rsync_prefix (which includes if config.rsyncOptionsEnabled(): cmd.extend(shlex.split(config.rsyncOptions()))) is only set in the takeSnapshot routine, not in the remove routine.
Shouldn't the rsyncOptions also be used in the remove routine? This was already requested in #1507, but for another reason.

How can I work around this? Is it safe to manually run the rsync -a --delete -s /tmp/tmps8asu05e/ /mnt/databackup/backintime/backintime/gentoo/root/1/20240502-194442-488 command with the --max-alloc=5g option? Should I then create an empty directory /tmp/tmps8asu05e/ first?
Or just remove the /mnt/databackup/backintime/backintime/gentoo/root/1/20240502-194442-488 directory?

I've also set the RSYNC_MAX_ALLOC environment variable to 5g (as described in the rsync man page), but this doesn't make a difference.

backintime --diagnostics  
{  
   "backintime": {  
       "name": "Back In Time",  
       "version": "1.3.3",  
       "latest-config-version": 6,  
       "local-config-file": "/home/UsernameReplaced/.config/backintime/config",  
       "local-config-file-found": false,  
       "global-config-file": "/etc/backintime/config",  
       "global-config-file-found": false,  
       "started-from": "/usr/share/backintime/common",  
       "running-as-root": false,  
       "user-callback": "/home/UsernameReplaced/.config/backintime/user-callback",  
       "keyring-supported": false  
   },  
   "host-setup": {  
       "platform": "Linux-6.10.6-gentoo-dist-x86_64-AMD_Ryzen_9_7900X_12-Core_Processor-with-glibc2.39",  
       "system": "Linux #1 SMP PREEMPT_DYNAMIC Tue Aug 20 18:54:03 CEST 2024",  
       "os-release": {  
           "NAME": "Gentoo",  
           "ID": "gentoo",  
           "PRETTY_NAME": "Gentoo Linux",  
           "ANSI_COLOR": "1;32",  
           "HOME_URL": "https://www.gentoo.org/",  
           "SUPPORT_URL": "https://www.gentoo.org/support/",  
           "BUG_REPORT_URL": "https://bugs.gentoo.org/",  
           "VERSION_ID": "2.15"  
       },  
       "display-system": "wayland",  
       "locale": "en_US, UTF-8",  
       "PATH": "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin:/usr/lib/llvm/18/bin",  
       "RSYNC_OLD_ARGS": "(not set)",  
       "RSYNC_PROTECT_ARGS": "(not set)"  
   },  
   "python-setup": {  
       "python": "3.12.3 main Jun  8 2024 10:56:55 CPython GCC 13.2.1 20240210",  
       "python-executable": "/usr/lib/python-exec/python3.12/python3",  
       "python-executable-symlink": true,  
       "python-executable-resolved": "/usr/bin/python3.12",  
       "sys.path": [  
           "/usr/share/backintime/qt/plugins",  
           "/usr/share/backintime/common/plugins",  
           "/usr/share/backintime/plugins",  
           "/usr/share/backintime/common",  
           "/usr/lib/python312.zip",  
           "/usr/lib/python3.12",  
           "/usr/lib/python3.12/lib-dynload",  
           "/usr/lib/python3.12/site-packages"  
       ],  
       "qt": "PyQt 5.15.11 / Qt 5.15.14"  
   },  
   "external-programs": {  
       "rsync": {  
           "program": "rsync",  
           "version": "3.3.0",  
           "protocol": "31.0",  
           "copyright": "(C) 1996-2024 by Andrew Tridgell, Wayne Davison, and others.",  
           "url": "https://rsync.samba.org/",  
           "capabilities": {  
               "file_bits": 64,  
               "inum_bits": 64,  
               "timestamp_bits": 64,  
               "long_int_bits": 64,  
               "socketpairs": true,  
               "symlinks": true,  
               "symtimes": true,  
               "hardlinks": true,  
               "hardlink_specials": true,  
               "hardlink_symlinks": true,  
               "IPv6": true,  
               "atimes": true,  
               "batchfiles": true,  
               "inplace": true,  
               "append": true,  
               "ACLs": true,  
               "xattrs": true,  
               "secluded_args": "optional",  
               "iconv": true,  
               "prealloc": true,  
               "stop_at": true,  
               "crtimes": false  
           },  
           "optimizations": {  
               "SIMD_roll": true,  
               "asm_roll": false,  
               "openssl_crypto": true,  
               "asm_MD5": false  
           },  
           "checksum_list": [  
               "md5",  
               "md4",  
               "sha1",  
               "none"  
           ],  
           "compress_list": [  
               "zlibx",  
               "zlib",  
               "none"  
           ],  
           "daemon_auth_list": [  
               "sha512",  
               "sha256",  
               "sha1",  
               "md5",  
               "md4"  
           ],  
           "license": "GPLv3",  
           "caveat": "rsync comes with ABSOLUTELY NO WARRANTY"  
       },  
       "ssh": "OpenSSH_9.7p1, OpenSSL 3.0.13 30 Jan 2024",  
       "sshfs": "3.7.3",  
       "encfs": "(no encfs)",  
       "shell": "/bin/bash",  
       "shell-version": "GNU bash, version 5.2.26(1)-release (x86_64-pc-linux-gnu)"  
   }  
}
@buhtz
Copy link
Member

buhtz commented Sep 4, 2024

Thank you for this detailed report.

I wonder if it might be more secure to separate the "additional rsync options" between take snapshot & remove. Maybe an extra dialog window offering three fields: "additional rsync options..." 1) for all rsync operations 2) for take snapshot only 3) for remove snapshots.

I wouldn't recommend to run rsync your self as you suggested.

Anyway. It wonders me that setting the environment variable has no effect. To my knowledge this should work. RSYNC_MAX_ALLOC is supported by rsync since version 3.2.2. You are at 3.3.0.

What about your error message when using the environment variable? Do you still see "exceeded --max-alloc=1073741824 setting" or something like "exceeded --max-alloc=5G setting"?

Can you run BIT with "--debug" please. There you can find the real rsync-command used for removing snapshots. I couldn't find an indication in the source code but it might be that somewhere else --max-alloc is explicit set and that is why the environment variable is ignored.

@buhtz buhtz added Feature requests a new feature Discussion decision or consensus needed Bug External depends on others/upstream labels Sep 4, 2024
@buhtz buhtz added this to the 2nd release from now milestone Sep 4, 2024
@buhtz buhtz changed the title rsyncOptions not included when removing snapshot Bug/Feature: "additional options to rsync" not used when removing snapshots Sep 4, 2024
@xelvinc
Copy link
Author

xelvinc commented Sep 4, 2024

Thanks for your quick reply. I'll run BiT with "--debug" later today. I've got the snapshot removed in the end by repeatedly removing it until it was completely removed, so I'm not sure if I can reproduce myself anymore.

@xelvinc
Copy link
Author

xelvinc commented Sep 4, 2024

Output with --debug:

DEBUG: [qt/app.py:1545 Execute.run] Call command "rsync -a --delete -s /tmp/tmpaw6c8_5y/ /mnt/databackup/backintime/backintime/gentoo/root/1/20240202-143318-346"
WARNING: [qt/app.py:1545 Execute.run] Command "rsync -a --delete -s /tmp/tmpaw6c8_5y/ /mnt/databackup/backintime/backintime/gentoo/root/1/20240202-143318-346" returns 22 | [generator] exceeded --max-alloc=1073741824 setting (file=ifuncs.h, line=30)
rsync error: error allocating core memory buffers (code 22) at util2.c(80) [generator=3.3.0]
ERROR: [common/snapshots.py:642 remove] Last rsync command failed with return code "22". See previous WARNING message in the logs for details.

I double check the environmental variable with the env command, it looks correct:
RSYNC_MAX_ALLOC=5g
Also tried with:
RSYNC_MAX_ALLOC=5368709120
and with:
RSYNC_MAX_ALLOC=0
All with the same result.

Could it be that the python script is running in it's own environment and therefor the systems environment variables are ignored?

@buhtz
Copy link
Member

buhtz commented Sep 4, 2024

Could it be that the python script is running in it's own environment and therefor the systems environment variables are ignored?

Yes, that is the case. I always forget that. For your workaround open the starter scripts /usr/bin/backintime and /usr/bin/backintime-qt. One way would be to remove the -E option. But I am not sure about side effects.

I tried to reproduce the behavior with that script:

#!/usr/bin/env python3
# foo.py
import os
print(os.environ)

And calling it:

$ python3 -Es foo.py

But I still see all (?) environment variables. I would expect I wouldn't see them. I am confused.

@xelvinc
Copy link
Author

xelvinc commented Sep 4, 2024

Same here. I'm also not sure if this is the way to go. It might add additional challenges to get it working with cron, but I'm not sure.
[]https://cronitor.io/guides/cron-environment-variables

Your proposal with the 3 fields sounds good to me.

@buhtz
Copy link
Member

buhtz commented Sep 4, 2024

Another short term workaround for you would be to directly edit tools.py in your installation and add the extra option.

cmd = ['rsync', '-a', '--delete', '-s']

@xelvinc
Copy link
Author

xelvinc commented Sep 4, 2024

Yes, that worked. Thanks for the hint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Discussion decision or consensus needed External depends on others/upstream Feature requests a new feature
Projects
None yet
Development

No branches or pull requests

2 participants