Borg Restore Backup file without info.json

What type of hardware are you using: VPS bought online
What YunoHost version are you running: 12
What app is this about: borg

Describe your issue

as @erwan noted here Commande de restoration Borg Backup commande introuvable - #3 by erwan (it’s closed, that’s why I open a new thread) and in this github issue Borg Backup Restore procedure is not working · Issue #181 · YunoHost-Apps/borg_ynh · GitHub

there’s a problem with the .tarfile created following borg_ynh package instructions.

There’s actually a info.json inside the .tar, I have extracted (and renamed) it but it’s not correct (corrupt or invalid, whatever). I have iterated trying diferent names and looking inside that file (it seems correct to me compared to other backup json files) and with .tar.gz

Please anyone have succeded in using a backup file from borg in the last few weeks? any workaround?

I have only notice this in the last few days trying to restore a backup after migration to ynh12.

Thank you.

Share relevant logs or error messages

Erreur : Impossible d’avoir des informations sur l’archive ‘/home/yunohost.backup/archives/auto_wordpress-2024-10-11T00:04:50.tar’… Le fichier info.json ne peut pas être trouvé (ou n’est pas un fichier json valide).
root@rogu:/home/yunohost.backup/archives#

What worked for me:

sudo -i
$ app=borg
$ PATH="/var/www/$app/venv/bin/:$PATH"
$ export BORG_PASSPHRASE="$(sudo yunohost app setting $app passphrase)" 
$ export BORG_RSH="ssh -i /root/.ssh/id_${app}_ed25519 -oStrictHostKeyChecking=yes"
$ repository="$(sudo yunohost app setting $app repository)"

# export the backup named NAME_OF_BACKUP to a file called some_name.tar
$ borg export-tar "$repository::NAME_OF_BACKUP" /home/yunohost.backup/archives/some_name.tar

# find the info.json
$tar --wildcards -tvf /home/yunohost.backup/archives/some_name.tar  '*.json'

# export the info.json
$  tar -axf /home/yunohost.backup/archives/some_name.tar  home/yunohost.backup/tmp/auto_some_name/info.json -O > /home/yunohost.backup/archives/some_name.info.json

The backup should now be visible in web admin.

1 Like

thank you for your reply :hugs: , it is about the same I did (and now repeated using a backup from a different day just in case), but the some_name.info.json extracted is not «valid». Yes, backup is listed after extracting that file:

root@ynh: yunohost backup list
archives: 
  - borg-pre-upgrade2
  - ntfy-0711
root@ynh:/home/yunohost.backup/archives# yunohost backup restore ntfy-0711
Info: Preparing archive for restoration…
Error: Could not load info for archive '/home/yunohost.backup/archives/ntfy-0711.tar'… The info.json file cannot be retrieved (or is not a valid json).

that’s the problem.

ls -la /home/yunohost.backup/archives/
total 51800
drwxrwx--- 2 root admins     4096 Nov 13 15:04 .
drwxrwx--- 5 root admins     4096 Nov 13 00:00 ..
-rw-r--r-- 1 root root        337 Nov  9 16:56 borg-pre-upgrade2.info.json
-rw-r--r-- 1 root root     143360 Nov  9 16:56 borg-pre-upgrade2.tar
-rw-r--r-- 1 root root        291 Nov 13 15:04 ntfy-0711.info.json
-rw------- 1 root root   52879360 Nov 13 15:02 ntfy-0711.tar

yes, chmod 644 ntfy-0711.tar too (just in case)

edit: that borg-pre-upgrade backup was automatically created by the system at the time (not related to problem, I just did not delete it)

thank you (honest)

I think this is a bug in core, the file needs to be moved to root of tar file.

On a second thought you need to repackage the whole tar, stripping paths until info.json is in the root.

1 Like

I have moved both info.json and bakcup.csv to .tar file’s root (as in other .tar backups) but it also fails to restore.

tar -xvf ntfy-0711.tar home/yunohost.backup/tmp/auto_ntfy/backup.csv
tar -xvf ntfy-0711.tar home/yunohost.backup/tmp/auto_ntfy/info.json
tar -rvf ntfy-0711.tar home/yunohost.backup/tmp/auto_ntfy/backup.csv
tar -rvf ntfy-0711.tar home/yunohost.backup/tmp/auto_ntfy/info.json
tar -tvf ntfy-0711.tar
# lists all files included in ntfy-0711.tar
...
-rw-r--r-- root/root       163 2024-11-07 00:08 home/yunohost.backup/tmp/auto_ntfy/apps/ntfy/settings/permissions.yml
-rw-r--r-- root/root       291 2024-11-13 15:04 info.json
-rw-r--r-- root/root       606 2024-11-07 00:08 backup.csv
root@ynh:/home/yunohost.backup/archives# yunohost backup restore ntfy-0711 --debug
93   DEBUG   acquiring lock...
102  DEBUG   lock has been acquired
115  DEBUG   loading python module yunohost.backup took 0.013s
116  DEBUG   processing action 'yunohost.backup.restore'
116  INFO    Preparing archive for restoration…
117  DEBUG   Extracting needed files from the archive…
455  DEBUG   restoring from backup 'ntfy-0711' created on 2024-11-06 23:08:46
462  INFO    Restoring ntfy…
463  WARNING ntfy will not be restored
490  DEBUG   initializing root ldap interface
504  DEBUG   The permission database has been resynchronized
520  DEBUG   SSO and portal configurations regenerated
527  SUCCESS Restoration completed
527  DEBUG   action executed in 0.411s
527  DEBUG   lock has been released
apps: 
  ntfy: Warning
system:

thank you for your suggestion (I’ve also tried moving just info.json)

I think I better wait “someone” solves it :magic_wand: before I break my ynh :smiley: . Crossed fingers I’m not going to need to restore untill then (ntfy is not that important to me)
thanks

What worked for me is to untar the archive, then re-tar it with different root:

$ tar xf backup_file.tar
# this will create `home/yunohost.backup/tmp` folder with contents, we need to strip the path

$ tar cv -C home/yunohost.backup/tmp . > repackaged.tar
$ mv backupfile.info.json repackaged.info.json

You should now be able to restore repackaged.tar backup file.

EDIT: Also, the internet claims there’s archivemount command so you don’t even have to extract the contents of original archive, merely mount it somewhere and prepend the path to -C option of tar command.

thank you

I’ve now tested and it did not work for me.

I hope this thread was at least useful for anyone with the same problem and reading your kind suggestions.

Hey guys,
I tried to migrate from Debian 11 to 12 on the last weekend and noticed the same issue as it is described here. The idea was to combine the migration also with a VPS migration. Creating a backup via GUI on the old VPS and restoring on the new one worked fine but mounting the existing borg backup failed sadly. I also followed orhtej2´s description to make the backup visible but related to the packaging of the data in the tar the procedure of recovery failed.
Just for my understanding: is the root cause of how the data is packaged located in the handling of borg or what exactly happened?
When I installed the borg application on my new VPS I also realised that I have to install the package also via SSH via apt install borgbackup to handle the commands on the cli. Perhaps I mix up some memories but was this also necessary in the past? I thought installing the app in the GUI already includes all packages required.

I can confirm that restoring a Borg backup does not work for me, following the guides in this thread. I am grateful for the work being done to eventually solve this. Thank you.

Edit: After reading the linked bug report and the other forum posts regarding this thread, I conclude that (for me, at least) Borg does not create backups that are restorable by the Yunohost backup restore command. This basically means Borg backups do not work for me.