YunoHost-Apps / wireguard_ynh

WireGuard VPN software with a web UI configuration companion, packaged for YunoHost.
GNU General Public License v3.0
35 stars 10 forks source link

Borgbackup automatic backup fails: WARNING - Could not link /etc/wireguard/wg0.conf to ... #70

Closed lightnin closed 1 year ago

lightnin commented 2 years ago

After installing wireguard app yesterday, automatic borgbackup nightly backups that used to work fail. Filing this here because I think it's likely something configurable per app, and not the fault of borgbackup - but please correct me if wrong.

Collecting files to be backed up for wireguard... Loading installation settings... Declaring files to be backed up... Backup script completed for wireguard. (YunoHost will then actually copy those files to the archive). Creating a backup archive from the collected files... The archive will contain about 19.3MiB of data. The operation 'Create a backup archive' could not be completed. Please share the full log of this operation using the command 'yunohost log share 20220706-231530-backup_create' to get help

Here is the log: https://paste.yunohost.org/raw/acomiyexik

This appears to be significant part: 2022-07-07 00:15:38,388: WARNING - Could not link /etc/wireguard/wg0.conf to /home/yunohost.backup/tmp/auto_wireguard/apps/wireguard/backup/etc/wireguard/wg0.conf ([Errno 17] File exists: '/etc/wireguard/wg0.conf' -> '/home/yunohost.backup/tmp/auto_wireguard/apps/wireguard/backup/etc/wireguard/wg0.conf') ... falling back to regular copy. 2022-07-07 00:15:38,399: DEBUG - Copying 0.0016202926635742188MB to organize the archive

Thanks for all you do to make this great free software!

tituspijean commented 2 years ago

@ljf, any idea what's the matter with the file?

SiM commented 2 years ago

Hi, same error here

lightnin commented 2 years ago

Also worth noting that adding an exception to borgbackup to not backup wireguard in app settings no longer prevents the system from trying to back it up since the migration to bullseye. So the presence of the wireguard app on my system consistently causes the borgbackup service to fail, thus preventing automatic backups.

shukon commented 1 year ago
The traceback: ``` Could not link /etc/wireguard/wg0.conf to /home/yunohost.backup/tmp/auto_wireguard/apps/wireguard/backup/etc/wireguard/wg0.conf ([Errno 17] File exists: '/etc/wireguard/wg0.conf' -> '/home/yunohost.backup/tmp/auto_wireguard/apps/wireguard/backup/etc/wireguard/wg0.conf') ... falling back to regular copy. Traceback (most recent call last): File "/usr/bin/yunohost", line 77, in yunohost.cli( File "/usr/lib/python3/dist-packages/yunohost/__init__.py", line 41, in cli ret = moulinette.cli( File "/usr/lib/python3/dist-packages/moulinette/__init__.py", line 111, in cli Cli( File "/usr/lib/python3/dist-packages/moulinette/interfaces/cli.py", line 507, in run ret = self.actionsmap.process(args, timeout=timeout) File "/usr/lib/python3/dist-packages/moulinette/actionsmap.py", line 584, in process return func(**arguments) File "/usr/lib/python3/dist-packages/yunohost/log.py", line 410, in func_wrapper result = func(*args, **kwargs) File "/usr/lib/python3/dist-packages/yunohost/backup.py", line 2279, in backup_create backup_manager.backup() File "/usr/lib/python3/dist-packages/yunohost/backup.py", line 772, in backup method.mount_and_backup() File "/usr/lib/python3/dist-packages/yunohost/backup.py", line 1698, in mount_and_backup self._organize_files() File "/usr/lib/python3/dist-packages/yunohost/backup.py", line 1856, in _organize_files shutil.copy(path["source"], dest) File "/usr/lib/python3.9/shutil.py", line 418, in copy copyfile(src, dst, follow_symlinks=follow_symlinks) File "/usr/lib/python3.9/shutil.py", line 244, in copyfile raise SameFileError("{!r} and {!r} are the same file".format(src, dst)) shutil.SameFileError: '/etc/wireguard/wg0.conf' and '/home/yunohost.backup/tmp/auto_wireguard/apps/wireguard/backup/etc/wireguard/wg0.conf' are the same file ```

How is this specific to the wireguard - borg combo? Any hints on where to investigate?

jorge-vitrubio commented 1 year ago

same here, no solution found and it is anoying:

cat /var/log/yunohost/categories/operation/20230627-000322-backup_create.yml
args:
  apps:
  - wireguard
  description: null
  dry_run: false
  methods:
  - borg_app
  name: auto_wireguard
  output_directory: null
  system: null
ended_at: 2023-06-27 00:03:25.577427
error: '''/etc/wireguard/wg0.conf'' and ''/home/yunohost.backup/tmp/auto_wireguard/apps/wireguard/backup/etc/wireguard/wg0.conf''
  are the same file'
interface: cli
operation: backup_create
parent: null
related_to:
- - app
  - wireguard
started_at: 2023-06-27 00:03:22.479313
success: false
yunohost_version: 11.1.21.4

also no effect even if i try to put wireguard in the exceptions for the borg backup... :/

for me the solution is to use the exact value of the apps to backup, for example:

yunohost app setting borg apps -v "etherpad_mypads,nextcloud,onlyoffice"
magostinelli commented 1 year ago

Same problem here.

We can backup everything exept wireguard, in this way if you add a new app, it will be backupped.

jose1711 commented 1 year ago

The issue is a combination of these two lines inside /etc/yunohost/apps/wireguard/scripts/backup:

ynh_backup --src_path="/etc/wireguard"
ynh_backup --src_path="$(jq -r ".config_file_path" $install_dir/db/server/global_settings.json)" --not_mandatory

and a situation where global_settings.json contains path starting with /etc/wireguard:

$ jq -r ".config_file_path" /var/www/wireguard/db/server/global_settings.json
/etc/wireguard/wg0.conf

If you're positive you're not using config files outside of /etc/wireguard a workaround would be commenting out the latter line.