mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Implement backup - restore and update test
This commit is contained in:
parent
4c2ae4fc77
commit
b01e4b61f5
6 changed files with 27 additions and 9 deletions
|
@ -13,5 +13,7 @@ backup_dir="${1}/conf/ldap"
|
||||||
ynh_backup "/etc/ldap/slapd.conf" "${backup_dir}/slapd.conf"
|
ynh_backup "/etc/ldap/slapd.conf" "${backup_dir}/slapd.conf"
|
||||||
sudo slapcat -b cn=config -l "${backup_dir}/cn=config.master.ldif"
|
sudo slapcat -b cn=config -l "${backup_dir}/cn=config.master.ldif"
|
||||||
|
|
||||||
# Backup the database
|
# Backup the database (all but not the permission except the permission for mail, metronome and sftp
|
||||||
sudo slapcat -b dc=yunohost,dc=org -l "${backup_dir}/dc=yunohost-dc=org.ldif"
|
sudo slapcat -b dc=yunohost,dc=org \
|
||||||
|
-H 'ldap:///dc=yunohost,dc=org???(|(!(objectClass=permissionYnh))(cn=main.mail)(cn=main.metronome)(cn=main.sftp))' \
|
||||||
|
-l "${backup_dir}/dc=yunohost-dc=org.ldif"
|
||||||
|
|
|
@ -105,6 +105,7 @@
|
||||||
"backup_output_directory_not_empty": "The output directory is not empty",
|
"backup_output_directory_not_empty": "The output directory is not empty",
|
||||||
"backup_output_directory_required": "You must provide an output directory for the backup",
|
"backup_output_directory_required": "You must provide an output directory for the backup",
|
||||||
"backup_output_symlink_dir_broken": "You have a broken symlink instead of your archives directory '{path:s}'. You may have a specific setup to backup your data on an other filesystem, in this case you probably forgot to remount or plug your hard dirve or usb key.",
|
"backup_output_symlink_dir_broken": "You have a broken symlink instead of your archives directory '{path:s}'. You may have a specific setup to backup your data on an other filesystem, in this case you probably forgot to remount or plug your hard dirve or usb key.",
|
||||||
|
"backup_permission": "Backup permission for app {app:s}",
|
||||||
"backup_php5_to_php7_migration_may_fail": "Could not convert your archive to support php7, your php apps may fail to restore (reason: {error:s})",
|
"backup_php5_to_php7_migration_may_fail": "Could not convert your archive to support php7, your php apps may fail to restore (reason: {error:s})",
|
||||||
"backup_running_app_script": "Running backup script of app '{app:s}'…",
|
"backup_running_app_script": "Running backup script of app '{app:s}'…",
|
||||||
"backup_running_hooks": "Running backup hooks…",
|
"backup_running_hooks": "Running backup hooks…",
|
||||||
|
|
|
@ -685,6 +685,12 @@ class BackupManager():
|
||||||
raise_on_error=True, chdir=tmp_app_bkp_dir, env=env_dict)
|
raise_on_error=True, chdir=tmp_app_bkp_dir, env=env_dict)
|
||||||
|
|
||||||
self._import_to_list_to_backup(env_dict["YNH_BACKUP_CSV"])
|
self._import_to_list_to_backup(env_dict["YNH_BACKUP_CSV"])
|
||||||
|
|
||||||
|
# backup permissions
|
||||||
|
logger.debug(m18n.n('backup_permission', app=app))
|
||||||
|
ldap_url = "ldap:///dc=yunohost,dc=org???(&(objectClass=permissionYnh)(cn=*.%s))" % app
|
||||||
|
os.system("slapcat -b dc=yunohost,dc=org -H '%s' -l '%s/permission.ldif'" % (ldap_url, settings_dir))
|
||||||
|
|
||||||
except:
|
except:
|
||||||
abs_tmp_app_dir = os.path.join(self.work_dir, 'apps/', app)
|
abs_tmp_app_dir = os.path.join(self.work_dir, 'apps/', app)
|
||||||
shutil.rmtree(abs_tmp_app_dir, ignore_errors=True)
|
shutil.rmtree(abs_tmp_app_dir, ignore_errors=True)
|
||||||
|
@ -1279,6 +1285,9 @@ class RestoreManager():
|
||||||
filesystem.chmod(app_settings_new_path, 0o400, 0o400, True)
|
filesystem.chmod(app_settings_new_path, 0o400, 0o400, True)
|
||||||
filesystem.chown(app_scripts_new_path, 'admin', None, True)
|
filesystem.chown(app_scripts_new_path, 'admin', None, True)
|
||||||
|
|
||||||
|
# Restore permissions
|
||||||
|
os.system("slapadd -l '%s/permission.ldif'" % app_settings_in_archive)
|
||||||
|
|
||||||
# Copy the app scripts to a writable temporary folder
|
# Copy the app scripts to a writable temporary folder
|
||||||
# FIXME : use 'install -Dm555' or something similar to what's done
|
# FIXME : use 'install -Dm555' or something similar to what's done
|
||||||
# in the backup method ?
|
# in the backup method ?
|
||||||
|
|
|
@ -6,9 +6,11 @@ from yunohost.app import app_install, app_remove
|
||||||
from yunohost.domain import _get_maindomain, domain_url_available, _normalize_domain_path
|
from yunohost.domain import _get_maindomain, domain_url_available, _normalize_domain_path
|
||||||
|
|
||||||
# Instantiate LDAP Authenticator
|
# Instantiate LDAP Authenticator
|
||||||
auth_identifier = ('ldap', 'ldap-anonymous')
|
AUTH_IDENTIFIER = ('ldap', 'as-root')
|
||||||
auth_parameters = {'uri': 'ldap://localhost:389', 'base_dn': 'dc=yunohost,dc=org'}
|
AUTH_PARAMETERS = {'uri': 'ldapi://%2Fvar%2Frun%2Fslapd%2Fldapi',
|
||||||
auth = init_authenticator(auth_identifier, auth_parameters)
|
'base_dn': 'dc=yunohost,dc=org',
|
||||||
|
'user_rdn': 'gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth'}
|
||||||
|
auth = init_authenticator(AUTH_IDENTIFIER, AUTH_PARAMETERS)
|
||||||
|
|
||||||
|
|
||||||
# Get main domain
|
# Get main domain
|
||||||
|
|
|
@ -18,8 +18,10 @@ from yunohost.utils.error import YunohostError
|
||||||
maindomain = ""
|
maindomain = ""
|
||||||
|
|
||||||
# Instantiate LDAP Authenticator
|
# Instantiate LDAP Authenticator
|
||||||
AUTH_IDENTIFIER = ('ldap', 'ldap-anonymous')
|
AUTH_IDENTIFIER = ('ldap', 'as-root')
|
||||||
AUTH_PARAMETERS = {'uri': 'ldap://localhost:389', 'base_dn': 'dc=yunohost,dc=org'}
|
AUTH_PARAMETERS = {'uri': 'ldapi://%2Fvar%2Frun%2Fslapd%2Fldapi',
|
||||||
|
'base_dn': 'dc=yunohost,dc=org',
|
||||||
|
'user_rdn': 'gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth'}
|
||||||
auth = None
|
auth = None
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,8 +9,10 @@ from yunohost.domain import _get_maindomain
|
||||||
from yunohost.utils.error import YunohostError
|
from yunohost.utils.error import YunohostError
|
||||||
|
|
||||||
# Instantiate LDAP Authenticator
|
# Instantiate LDAP Authenticator
|
||||||
AUTH_IDENTIFIER = ('ldap', 'ldap-anonymous')
|
AUTH_IDENTIFIER = ('ldap', 'as-root')
|
||||||
AUTH_PARAMETERS = {'uri': 'ldap://localhost:389', 'base_dn': 'dc=yunohost,dc=org'}
|
AUTH_PARAMETERS = {'uri': 'ldapi://%2Fvar%2Frun%2Fslapd%2Fldapi',
|
||||||
|
'base_dn': 'dc=yunohost,dc=org',
|
||||||
|
'user_rdn': 'gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth'}
|
||||||
|
|
||||||
auth = init_authenticator(AUTH_IDENTIFIER, AUTH_PARAMETERS)
|
auth = init_authenticator(AUTH_IDENTIFIER, AUTH_PARAMETERS)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue