Skip to content

Commit

Permalink
[backup/restore] add distro function to backup folder
Browse files Browse the repository at this point in the history
  • Loading branch information
koivo committed Aug 25, 2018
1 parent 1134181 commit 3be4593
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,16 @@ def eEnv_resolve_multi(path):
def getBackupPath():
backuppath = config.plugins.configurationbackup.backuplocation.value
if backuppath.endswith('/'):
return backuppath + 'backup_' + boxtype
return backuppath + 'backup_' + distro + '_'+ boxtype
else:
return backuppath + '/backup_' + boxtype
return backuppath + '/backup_' + distro + '_'+ boxtype

def getOldBackupPath():
backuppath = config.plugins.configurationbackup.backuplocation.value
if backuppath.endswith('/'):
return backuppath + 'backup'
return backuppath + 'backup_' + boxtype
else:
return backuppath + '/backup'
return backuppath + '/backup_' + boxtype

def getBackupFilename():
return "enigma2settingsbackup.tar.gz"
Expand Down Expand Up @@ -292,7 +292,6 @@ def layoutFinished(self):
def setWindowTitle(self):
self.setTitle(_("Restore backups"))


def fill_list(self):
self.flist = []
self.path = getBackupPath()
Expand Down Expand Up @@ -365,6 +364,8 @@ def __init__(self, session, runRestore = False):
"cancel": self.close,
}, -1)
self.backuppath = getBackupPath()
# if path.exists(self.backuppath) == False:
# self.backuppath = getOldBackupPath()
if not path.isdir(self.backuppath):
self.backuppath = getOldBackupPath()
self.backupfile = getBackupFilename()
Expand Down
21 changes: 17 additions & 4 deletions lib/python/Plugins/SystemPlugins/SoftwareManager/ImageWizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
from Components.Pixmap import Pixmap, MovingPixmap, MultiPixmap
from os import popen, path, makedirs, listdir, access, stat, rename, remove, W_OK, R_OK
from enigma import eEnv
from boxbranding import getBoxType
from boxbranding import getBoxType, getImageDistro

from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigText, ConfigLocations, ConfigBoolean
from Components.Harddisk import harddiskmanager

boxtype = getBoxType()
distro = getImageDistro()

config.misc.firstrun = ConfigBoolean(default = True)
config.plugins.configurationbackup = ConfigSubsection()
Expand All @@ -31,14 +32,20 @@

def checkConfigBackup():
parts = [ (r.description, r.mountpoint) for r in harddiskmanager.getMountedPartitions(onlyhotplug = False)]
if boxtype in ('maram9', 'classm', 'axodin', 'axodinc', 'starsatlx', 'genius', 'evo'):
if boxtype in ('maram9', 'classm', 'axodin', 'axodinc', 'starsatlx', 'genius', 'evo', 'galaxym6'):
parts.append(('mtd backup','/media/backup'))
for x in parts:
if x[1] == '/':
parts.remove(x)
if len(parts):
for x in parts:
if x[1].endswith('/'):
fullbackupfile = x[1] + 'backup_' + distro + '_' + boxtype + '/' + backupfile
if fileExists(fullbackupfile):
config.plugins.configurationbackup.backuplocation.setValue(str(x[1]))
config.plugins.configurationbackup.backuplocation.save()
config.plugins.configurationbackup.save()
return x
fullbackupfile = x[1] + 'backup_' + boxtype + '/' + backupfile
if fileExists(fullbackupfile):
config.plugins.configurationbackup.backuplocation.setValue(str(x[1]))
Expand All @@ -52,6 +59,12 @@ def checkConfigBackup():
config.plugins.configurationbackup.save()
return x
else:
fullbackupfile = x[1] + '/backup_' + distro + '_' + boxtype + '/' + backupfile
if fileExists(fullbackupfile):
config.plugins.configurationbackup.backuplocation.setValue(str(x[1]))
config.plugins.configurationbackup.backuplocation.save()
config.plugins.configurationbackup.save()
return x
fullbackupfile = x[1] + '/backup_' + boxtype + '/' + backupfile
if fileExists(fullbackupfile):
config.plugins.configurationbackup.backuplocation.setValue(str(x[1]))
Expand All @@ -69,7 +82,7 @@ def checkConfigBackup():
def checkBackupFile():
backuplocation = config.plugins.configurationbackup.backuplocation.value
if backuplocation.endswith('/'):
fullbackupfile = backuplocation + 'backup_' + boxtype + '/' + backupfile
fullbackupfile = backuplocation + 'backup_' + distro + '_' + boxtype + '/' + backupfile
if fileExists(fullbackupfile):
return True
else:
Expand All @@ -79,7 +92,7 @@ def checkBackupFile():
else:
return False
else:
fullbackupfile = backuplocation + '/backup_' + boxtype + '/' + backupfile
fullbackupfile = backuplocation + '/backup_' + distro + '_' + boxtype + '/' + backupfile
if fileExists(fullbackupfile):
return True
else:
Expand Down

0 comments on commit 3be4593

Please sign in to comment.