Restore from folder rather then tar.gz

#1

Hi

Synapse gave me an error while upgrade and further the restore script gave error to while upgrade. So I lost synapse all together.
To restore the app from the backup archive, I need to extract the backup tar.gz from the archive fix the error in the restore and run the restore manually.

But when I create the synapse.tar.gz from this command $ tar czf synapse.tar.gz synapse/* and run $ yunohost backup restore synapse --debug . I got this error:

310  DEBUG loading actions map namespace 'yunohost'
331  DEBUG extra parameter classes loaded: ['comment', 'ask', 'password', 'required', 'pattern']
331  DEBUG initializing base actions map parser for cli
332  DEBUG registering new callback action 'yunohost.utils.packages.ynh_packages_version' to ['-v', '--version']
409  DEBUG initialize authenticator 'ldap-anonymous' with: uri='ldap://localhost:389', base_dn='dc=yunohost,dc=org', user_rdn='None'
416  DEBUG lock has been acquired
493  DEBUG loading python module yunohost.backup took 0.077s
494  INFO processing action [20312.1]: yunohost.backup.restore with args={'force': False, 'name': 'synapse', 'apps': None, 'system': None, 'auth': <moulinette.authenticators.ldap.Authenticator object at 0x7f00aac2b050>}
494  WARNING YunoHost is already installed
Do you really want to restore an already installed system? [y/N]: Y
12866 DEBUG unable to retrieve '/home/yunohost.backup/archives/synapse.info.json' inside the archive
Traceback (most recent call last):
  File "/usr/lib/moulinette/yunohost/backup.py", line 2233, in backup_info
    tar.extract('info.json', path=info_dir)
  File "/usr/lib/python2.7/tarfile.py", line 2109, in extract
    tarinfo = self.getmember(member)
  File "/usr/lib/python2.7/tarfile.py", line 1829, in getmember
    raise KeyError("filename %r not found" % name)
KeyError: "filename 'info.json' not found"
12868 DEBUG action [20312.1] executed in 12.375s
12868 DEBUG lock has been released
12869 ERROR Invalid backup archive
#2

info.json is present in your folder ?

#3

Yes its present. These files are present apps backup.csv info.json

#4

I think whe you tar again the content you tar the directory and not the content of the directory.

info.json need to be at the root of the archive

#5

Can you tell the command for the tar only the content of the folder in /home/yunohost.backup/archive/synapse to synapse.tar.gz ?

#6
cd /home/yunohost.backup/archive/synapse/ 
tar -zcvf ../synapse.tar.gz .
#7

@ljf
I tried as you suggested but its still failing. What I am doing wrong?

$ yunohost backup   restore   synapse  --debug 
193  DEBUG loading actions map namespace 'yunohost'
217  DEBUG extra parameter classes loaded: ['comment', 'ask', 'password', 'required', 'pattern']
217  DEBUG initializing base actions map parser for cli
219  DEBUG registering new callback action 'yunohost.utils.packages.ynh_packages_version' to ['-v', '--version']
319  DEBUG initialize authenticator 'ldap-anonymous' with: uri='ldap://localhost:389', base_dn='dc=yunohost,dc=org', user_rdn='None'
323  DEBUG lock has been acquired
468  DEBUG loading python module yunohost.backup took 0.144s
468  INFO processing action [31673.1]: yunohost.backup.restore with args={'force': False, 'name': 'synapse', 'apps': None, 'system': None, 'auth': <moulinette.authenticators.ldap.Authenticator object at 0x7f9f62cff050>}
468  WARNING YunoHost is already installed
Do you really want to restore an already installed system? [y/N]: Y
13792 DEBUG unable to retrieve '/home/yunohost.backup/archives/synapse.info.json' inside the archive
Traceback (most recent call last):
  File "/usr/lib/moulinette/yunohost/backup.py", line 2233, in backup_info
    tar.extract('info.json', path=info_dir)
  File "/usr/lib/python2.7/tarfile.py", line 2109, in extract
    tarinfo = self.getmember(member)
  File "/usr/lib/python2.7/tarfile.py", line 1829, in getmember
    raise KeyError("filename %r not found" % name)
KeyError: "filename 'info.json' not found"
13797 DEBUG action [31673.1] executed in 13.328s
13797 DEBUG lock has been released
13798 ERROR Invalid backup archive
#8

What is the output of :

#9

There are lot of my backups but synapse related files are:

drwxr-xr-x 3 root root        4096 May  7 18:24 synapse
-rw-r--r-- 1 root root         272 May  6 01:26 synapse-pre-upgrade2.info.json
-rw-r--r-- 1 root root   199269186 May  6 01:26 synapse-pre-upgrade2.tar.gz
-rw-r--r-- 1 root root   206604819 May  8 22:43 synapse.tar.gz

I have extracted synapse-pre-upgrade2.tar.gz to synapse folder, did changes in restore script and created the synapse.tar.gz as you told in above comment.

#10

Cant I restore from the folder ?

#11

Sorry I did not saw full path

These are the content of the synpse folder.

apps backup.csv info.json

#12

Pour voir ce qu’il y a dans le tar gz
tar -ztvf synapse.tar.gz | grep info.json

?

#13

-rw-r–r-- root/root 272 2019-05-06 01:24 ./info.json

#14

Try to extract the info.json and put it on this path:

Are you up to date on your yunohost?

#15

I have done it already done.

I have found the the bug. The compression is taking ./ as the path, but it should be without ./ as I see in the original backup.

-rw-r–r-- root/root 272 2019-05-06 01:24 ./info.json

Do you know how to tar without the ./ path ?

#16

Follow-up of discussion on the forum : for tar, foo is not the same as ./foo

A quickfix for this is to use tar -zcvf ../synapse.tar.gz * instead of tar -zcvf ../synapse.tar.gz .

A more longterm fix is https://github.com/YunoHost/yunohost/pull/726 though I don’t know how relevant it is considering this is really an edge case of “repackaging a backup archive manually”

1 Like