From 1a06c4d7b2608bf0920c55d3c851b8b4fdb567f3 Mon Sep 17 00:00:00 2001 From: kload Date: Sun, 26 Oct 2014 00:15:46 +0200 Subject: [PATCH] [fix] Add backup and restore hooks from scripts dir --- backup.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/backup.py b/backup.py index 39e1feb81..c4c708255 100644 --- a/backup.py +++ b/backup.py @@ -28,6 +28,7 @@ import sys import json import errno import time +import shutil from moulinette.core import MoulinetteError @@ -47,6 +48,15 @@ def backup_backup(): os.system('chmod 755 /home/yunohost.backup /home/yunohost.backup/tmp') os.system('chown -hR admin: %s' % backup_dir) + # Add app's backup hooks + try: + for app_id in os.listdir('/etc/yunohost/apps'): + hook = '/etc/yunohost/apps/'+ app_id +'/scripts/backup' + with open(hook, 'r') as f: + hook_add(app_id, hook) + except IOError: + pass + # Run hook hook_callback('backup', [backup_dir]) @@ -64,6 +74,7 @@ def backup_restore(path): """ from yunohost.tools import tools_postinstall + from yunohost.hook import hook_add from yunohost.hook import hook_callback path = os.path.abspath(path) @@ -82,6 +93,15 @@ def backup_restore(path): except IOError: tools_postinstall(domain, 'yunohost', True) + # Add app's restore hooks + try: + for app_id in os.listdir('/etc/yunohost/apps'): + hook = '/etc/yunohost/apps/'+ app_id +'/scripts/restore' + with open(hook, 'r') as f: + hook_add(app_id, hook) + except IOError: + pass + # Run hook hook_callback('restore', [path])