diff --git a/actionsmap/yunohost.yml b/actionsmap/yunohost.yml index a3012d582..21bc23094 100644 --- a/actionsmap/yunohost.yml +++ b/actionsmap/yunohost.yml @@ -559,12 +559,8 @@ backup: ### backup_init() init: - action_help: Init Tahoe-LAFS configuration - # api: POST /backup/init - arguments: - --helper: - help: Init as a helper node rather than a "helped" one - action: store_true + action_help: Create an encrypted backup tarball + api: POST /backup ############################# @@ -1025,8 +1021,8 @@ tools: pattern: - '^.{3,}$' - pattern_password - --dyndns: - help: Subscribe domain to a DynDNS service + --ignore-dyndns: + help: Do not subscribe domain to a DynDNS service action: store_true ### tools_update() diff --git a/backup.py b/backup.py index 12b629d4e..e51e22885 100644 --- a/backup.py +++ b/backup.py @@ -26,27 +26,27 @@ import os import sys import json -import yaml -import glob +import time from moulinette.core import MoulinetteError -def backup_init(helper=False): +def backup(): """ - Init Tahoe-LAFS configuration - - Keyword argument: - helper -- Init as a helper node rather than a "helped" one + Create an encrypted backup tarball """ - tahoe_cfg_dir = '/usr/share/yunohost/yunohost-config/backup' - if helper: - configure_cmd = '/configure_tahoe.sh helper' - else: - configure_cmd = '/configure_tahoe.sh' + from yunohost.hook import hook_callback - os.system('tahoe create-client /home/yunohost.backup/tahoe') - os.system('/bin/bash %s%s' % (tahoe_cfg_dir, configure_cmd)) - os.system('cp %s/tahoe.cfg /home/yunohost.backup/tahoe/' % tahoe_cfg_dir) - #os.system('update-rc.d tahoe-lafs defaults') - #os.system('service tahoe-lafs restart') + backup_dirname = int(time.time()) + backup_dir = "/home/yunohost.backup/tmp/%s" % backup_dirname + + # Create directory + try: os.listdir(backup_dir) + except OSError: os.makedirs(backup_dir) + + # Run hook + hook_callback('backup', [backup_dir]) + + #TODO: Compress & encrypt + + msignals.display(m18n.n('backup_completed'), 'success') diff --git a/locales/en.json b/locales/en.json index 65cf911fb..f615178fb 100644 --- a/locales/en.json +++ b/locales/en.json @@ -128,6 +128,8 @@ "packages_upgrade_failed" : "Unable to upgrade all packages", "system_upgraded" : "System successfully upgraded", + "backup_complete" : "Backup complete", + "field_invalid" : "Invalid field '{:s}'", "mail_domain_unknown" : "Unknown mail address domain '{:s}'", "mail_alias_remove_failed" : "Unable to remove mail alias '{:s}'", diff --git a/locales/fr.json b/locales/fr.json index 375ece04d..60880cb57 100644 --- a/locales/fr.json +++ b/locales/fr.json @@ -128,6 +128,8 @@ "packages_upgrade_failed" : "Impossible de mettre à jour tous les paquets", "system_upgraded" : "Système mis à jour avec succès", + "backup_complete" : "Sauvegarde terminée", + "field_invalid" : "Champ incorrect : {:s}", "mail_domain_unknown" : "Domaine '{:s}' de l'adresse mail inconnu", "mail_alias_remove_failed" : "Impossible de supprimer l'adresse mail supplémentaire '{:s}'", diff --git a/tools.py b/tools.py index b58cb5149..82d7325c8 100644 --- a/tools.py +++ b/tools.py @@ -207,7 +207,7 @@ def tools_maindomain(auth, old_domain=None, new_domain=None, dyndns=False): msignals.display(m18n.n('maindomain_changed'), 'success') -def tools_postinstall(domain, password, dyndns=False): +def tools_postinstall(domain, password, ignore_dyndns=False): """ YunoHost post-install @@ -230,7 +230,7 @@ def tools_postinstall(domain, password, dyndns=False): else: raise MoulinetteError(errno.EPERM, m18n.n('yunohost_already_installed')) - if len(domain.split('.')) >= 3: + if len(domain.split('.')) >= 3 and not ignore_dyndns: try: r = requests.get('http://dyndns.yunohost.org/domains') except ConnectionError: @@ -310,9 +310,6 @@ def tools_postinstall(domain, password, dyndns=False): # Initialize YunoHost LDAP base tools_ldapinit(auth) - # Initialize backup system - backup_init() - # New domain config tools_maindomain(auth, old_domain='yunohost.org', new_domain=domain, dyndns=dyndns)