mirror of
https://github.com/robweber/xbmcbackup.git
synced 2024-11-14 20:35:48 +01:00
Merge branch 'gotham-dev'
Conflicts: addon.xml changelog.txt resources/language/Bulgarian/strings.xml
This commit is contained in:
commit
e025b3213c
33
README.txt
33
README.txt
@ -6,7 +6,7 @@ I've had to recover my database, thumbnails, and source configuration enough tim
|
|||||||
|
|
||||||
Remote Destination/File Selection:
|
Remote Destination/File Selection:
|
||||||
|
|
||||||
In the addon settings you can define a remote path for the destination of your xbmc files. Each backup will create a folder named in a YYYYMMDD format so you can create multiple backups. You can keep a set number of backups by setting the integer value of the Backups to Keep setting greater than 0.
|
In the addon settings you can define a remote path for the destination of your xbmc files. Each backup will create a folder named in a YYYYMMDDHHmm format so you can create multiple backups. You can keep a set number of backups by setting the integer value of the Backups to Keep setting greater than 0.
|
||||||
|
|
||||||
On the Backup Selection page you can select which items from your user profile folder will be sent to the backup location. By default all are turned on except the Addon Data directory.
|
On the Backup Selection page you can select which items from your user profile folder will be sent to the backup location. By default all are turned on except the Addon Data directory.
|
||||||
|
|
||||||
@ -37,11 +37,38 @@ Once you have your app key and secret add them to the settings. XBMC Backup now
|
|||||||
|
|
||||||
Scripting XBMC Backup:
|
Scripting XBMC Backup:
|
||||||
|
|
||||||
If you wish to script this addon using an outside scheduler or script it can be given parameters via the Xbmc.RunScript() or JsonRPC.Addons.ExecuteAddon() methods. Parameters given are either "backup" or "restore" to launch the correct program mode. An example would be:
|
If you wish to script this addon using an outside scheduler or script it can be given parameters via the Xbmc.RunScript() or JsonRPC.Addons.ExecuteAddon() methods. Parameters given are either "backup" or "restore" to launch the correct program mode. If mode is "restore", an additional "archive" parameter can be given to set the restore point to be used instead of prompting via the GUI. An example would be:
|
||||||
|
|
||||||
RunScript(script.xbmcbackup,backup)
|
Python code:
|
||||||
|
-------------------------------------------
|
||||||
|
RunScript(script.xbmcbackup,mode=backup)
|
||||||
|
-------------------------------------------
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
JSON Request:
|
||||||
|
-------------------------------------------
|
||||||
|
{ "jsonrpc": "2.0", "method": "Addons.ExecuteAddon","params":{"addonid":"script.xbmcbackup","params":{"mode":"restore","archive":"000000000000"}}, "id": 1 }
|
||||||
|
-------------------------------------------
|
||||||
|
|
||||||
|
There is also a windows parameter that can be used to check if XBMC Backup is running within a skin or from another program. It is attached to the home window, an example of using it would be the following:
|
||||||
|
|
||||||
|
Python code:
|
||||||
|
-------------------------------------------
|
||||||
|
#kick off the xbmc backup
|
||||||
|
xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Addons.ExecuteAddon","params":{"addonid":"script.xbmcbackup","params":{"mode":"backup"}}, "id": 1 }')
|
||||||
|
|
||||||
|
#sleep for a few seconds to give it time to kick off
|
||||||
|
xbmc.sleep(10000)
|
||||||
|
|
||||||
|
window = xbmcgui.Window(10000)
|
||||||
|
|
||||||
|
while (window.getProperty('script.xbmcbackup.running') == 'true'):
|
||||||
|
#do something here, probably just sleep for a few seconds
|
||||||
|
xbmc.sleep(5000)
|
||||||
|
|
||||||
|
#backup is now done, continue with script
|
||||||
|
-------------------------------------------
|
||||||
FAQ:
|
FAQ:
|
||||||
|
|
||||||
I can't see any restore points when choosing "Restore", what is the problem?
|
I can't see any restore points when choosing "Restore", what is the problem?
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<addon id="script.xbmcbackup"
|
<addon id="script.xbmcbackup"
|
||||||
name="XBMC Backup" version="0.4.7" provider-name="robweber">
|
name="XBMC Backup" version="0.5.2" provider-name="robweber">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="2.1.0"/>
|
<import addon="xbmc.python" version="2.12.0"/>
|
||||||
</requires>
|
</requires>
|
||||||
<extension point="xbmc.python.script" library="default.py">
|
<extension point="xbmc.python.script" library="default.py">
|
||||||
<provides>executable</provides>
|
<provides>executable</provides>
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
Version 0.4.7
|
Version 0.5.2
|
||||||
|
|
||||||
fixed critical error in backup rotation
|
added additional script and window parameters, thanks Samu-rai
|
||||||
|
|
||||||
|
critical error in backup rotation
|
||||||
|
|
||||||
|
Version 0.5.1
|
||||||
|
|
||||||
|
updated for new Gotham xbmc python updates
|
||||||
|
|
||||||
|
Version 0.5.0
|
||||||
|
|
||||||
|
New Version for Gotham
|
||||||
|
|
||||||
Version 0.4.6
|
Version 0.4.6
|
||||||
|
|
||||||
|
47
default.py
47
default.py
@ -1,21 +1,37 @@
|
|||||||
|
import urlparse
|
||||||
import xbmcgui
|
import xbmcgui
|
||||||
import resources.lib.utils as utils
|
import resources.lib.utils as utils
|
||||||
from resources.lib.backup import XbmcBackup
|
from resources.lib.backup import XbmcBackup
|
||||||
|
|
||||||
|
def get_params():
|
||||||
|
param = {}
|
||||||
|
|
||||||
|
if(len(sys.argv) > 1):
|
||||||
|
for i in sys.argv:
|
||||||
|
args = i
|
||||||
|
if(args.startswith('?')):
|
||||||
|
args = args[1:]
|
||||||
|
param.update(dict(urlparse.parse_qsl(args)))
|
||||||
|
|
||||||
|
return param
|
||||||
|
|
||||||
#the program mode
|
#the program mode
|
||||||
mode = -1
|
mode = -1
|
||||||
|
params = get_params()
|
||||||
|
|
||||||
#check if mode was passed in as an argument
|
|
||||||
if(len(sys.argv) > 1):
|
if("mode" in params):
|
||||||
if(sys.argv[1].lower() == 'backup'):
|
if(params['mode'] == 'backup'):
|
||||||
mode = 0
|
mode = 0
|
||||||
elif(sys.argv[1].lower() == 'restore'):
|
elif(params['mode'] == 'restore'):
|
||||||
mode = 1
|
mode = 1
|
||||||
|
|
||||||
|
#if mode wasn't passed in as arg, get from user
|
||||||
if(mode == -1):
|
if(mode == -1):
|
||||||
#figure out if this is a backup or a restore from the user
|
#figure out if this is a backup or a restore from the user
|
||||||
mode = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30023),[utils.getString(30016),utils.getString(30017)])
|
mode = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30023),[utils.getString(30016),utils.getString(30017)])
|
||||||
|
|
||||||
|
#check if program should be run
|
||||||
if(mode != -1):
|
if(mode != -1):
|
||||||
#run the profile backup
|
#run the profile backup
|
||||||
backup = XbmcBackup()
|
backup = XbmcBackup()
|
||||||
@ -23,14 +39,29 @@ if(mode != -1):
|
|||||||
if(backup.remoteConfigured()):
|
if(backup.remoteConfigured()):
|
||||||
|
|
||||||
if(mode == backup.Restore):
|
if(mode == backup.Restore):
|
||||||
#allow user to select the backup to restore from
|
#get list of valid restore points
|
||||||
restorePoints = backup.listBackups()
|
restorePoints = backup.listBackups()
|
||||||
pointNames = []
|
pointNames = []
|
||||||
|
folderNames = []
|
||||||
|
|
||||||
for aDir in restorePoints:
|
for aDir in restorePoints:
|
||||||
pointNames.append(aDir[1])
|
pointNames.append(aDir[1])
|
||||||
|
folderNames.append(aDir[0])
|
||||||
selectedRestore = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30021),pointNames)
|
|
||||||
|
selectedRestore = -1
|
||||||
|
|
||||||
|
if("archive" in params):
|
||||||
|
#check that the user give archive exists
|
||||||
|
if(params['archive'] in folderNames):
|
||||||
|
#set the index
|
||||||
|
selectedRestore = folderNames.index(params['archive'])
|
||||||
|
utils.log(str(selectedRestore) + " : " + params['archive'])
|
||||||
|
else:
|
||||||
|
utils.showNotification(utils.getString(30045))
|
||||||
|
utils.log(params['archive'] + ' is not a valid restore point')
|
||||||
|
else:
|
||||||
|
#allow user to select the backup to restore from
|
||||||
|
selectedRestore = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30021),pointNames)
|
||||||
|
|
||||||
if(selectedRestore != -1):
|
if(selectedRestore != -1):
|
||||||
backup.selectRestore(restorePoints[selectedRestore][0])
|
backup.selectRestore(restorePoints[selectedRestore][0])
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<string id="30019">Въвеждане на път</string>
|
<string id="30019">Въвеждане на път</string>
|
||||||
<string id="30020">Прегледайте</string>
|
<string id="30020">Прегледайте</string>
|
||||||
<string id="30021">Име на папката за резервните копия</string>
|
<string id="30021">Име на папката за резервните копия</string>
|
||||||
<string id="30022">Изпълнявай "тихо"</string>
|
<string id="30022">Известяване за напредъка</string>
|
||||||
<string id="30023">Режим</string>
|
<string id="30023">Режим</string>
|
||||||
<string id="30024">Въведете отдалечения път</string>
|
<string id="30024">Въведете отдалечения път</string>
|
||||||
<string id="30025">Окажете пътя до папката с резервни копия</string>
|
<string id="30025">Окажете пътя до папката с резервни копия</string>
|
||||||
@ -73,4 +73,7 @@
|
|||||||
<string id="30079">Само днес</string>
|
<string id="30079">Само днес</string>
|
||||||
<string id="30080">Профили</string>
|
<string id="30080">Профили</string>
|
||||||
<string id="30081">Планировчика ще стартира отново на</string>
|
<string id="30081">Планировчика ще стартира отново на</string>
|
||||||
|
<string id="30082">Лента за напредъка</string>
|
||||||
|
<string id="30083">Лента за напредъка на заден план</string>
|
||||||
|
<string id="30084">Без (тих режим)</string>
|
||||||
</strings>
|
</strings>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<string id="30019">Type Path</string>
|
<string id="30019">Type Path</string>
|
||||||
<string id="30020">Browse Remote Path</string>
|
<string id="30020">Browse Remote Path</string>
|
||||||
<string id="30021">Backup Folder Name</string>
|
<string id="30021">Backup Folder Name</string>
|
||||||
<string id="30022">Run Silent</string>
|
<string id="30022">Progress Display</string>
|
||||||
<string id="30023">Mode</string>
|
<string id="30023">Mode</string>
|
||||||
<string id="30024">Type Remote Path</string>
|
<string id="30024">Type Remote Path</string>
|
||||||
<string id="30025">Remote Path Type</string>
|
<string id="30025">Remote Path Type</string>
|
||||||
@ -73,4 +73,7 @@
|
|||||||
<string id="30079">Just Today</string>
|
<string id="30079">Just Today</string>
|
||||||
<string id="30080">Profiles</string>
|
<string id="30080">Profiles</string>
|
||||||
<string id="30081">Scheduler will run again on</string>
|
<string id="30081">Scheduler will run again on</string>
|
||||||
|
<string id="30082">Progress Bar</string>
|
||||||
|
<string id="30083">Background Progress Bar</string>
|
||||||
|
<string id="30084">None (Silent)</string>
|
||||||
</strings>
|
</strings>
|
||||||
|
@ -89,7 +89,11 @@ class XbmcBackup:
|
|||||||
def skipAdvanced(self):
|
def skipAdvanced(self):
|
||||||
self.skip_advanced = True
|
self.skip_advanced = True
|
||||||
|
|
||||||
def run(self,mode=-1,runSilent=False):
|
def run(self,mode=-1,progressOverride=False):
|
||||||
|
#set windows setting to true
|
||||||
|
window = xbmcgui.Window(10000)
|
||||||
|
window.setProperty(utils.__addon_id__ + ".running","true")
|
||||||
|
|
||||||
#append backup folder name
|
#append backup folder name
|
||||||
progressBarTitle = utils.getString(30010) + " - "
|
progressBarTitle = utils.getString(30010) + " - "
|
||||||
if(mode == self.Backup and self.remote_vfs.root_path != ''):
|
if(mode == self.Backup and self.remote_vfs.root_path != ''):
|
||||||
@ -107,8 +111,13 @@ class XbmcBackup:
|
|||||||
utils.log(utils.getString(30048) + ": " + self.remote_vfs.root_path)
|
utils.log(utils.getString(30048) + ": " + self.remote_vfs.root_path)
|
||||||
|
|
||||||
#check if we should use the progress bar
|
#check if we should use the progress bar
|
||||||
if(utils.getSetting('run_silent') == 'false' and not runSilent):
|
if(int(utils.getSetting('progress_mode')) != 2):
|
||||||
self.progressBar = xbmcgui.DialogProgress()
|
#check if background or normal
|
||||||
|
if(int(utils.getSetting('progress_mode')) == 0 and not progressOverride):
|
||||||
|
self.progressBar = xbmcgui.DialogProgress()
|
||||||
|
else:
|
||||||
|
self.progressBar = xbmcgui.DialogProgressBG()
|
||||||
|
|
||||||
self.progressBar.create(progressBarTitle,utils.getString(30049) + "......")
|
self.progressBar.create(progressBarTitle,utils.getString(30049) + "......")
|
||||||
|
|
||||||
if(mode == self.Backup):
|
if(mode == self.Backup):
|
||||||
@ -315,9 +324,12 @@ class XbmcBackup:
|
|||||||
#call update addons to refresh everything
|
#call update addons to refresh everything
|
||||||
xbmc.executebuiltin('UpdateLocalAddons')
|
xbmc.executebuiltin('UpdateLocalAddons')
|
||||||
|
|
||||||
if(utils.getSetting('run_silent') == 'false' and not runSilent):
|
if(self.progressBar != None):
|
||||||
self.progressBar.close()
|
self.progressBar.close()
|
||||||
|
|
||||||
|
#reset the window setting
|
||||||
|
window.setProperty(utils.__addon_id__ + ".running","")
|
||||||
|
|
||||||
def backupFiles(self,fileList,source,dest):
|
def backupFiles(self,fileList,source,dest):
|
||||||
utils.log("Writing files to: " + dest.root_path)
|
utils.log("Writing files to: " + dest.root_path)
|
||||||
utils.log("Source: " + source.root_path)
|
utils.log("Source: " + source.root_path)
|
||||||
@ -361,7 +373,7 @@ class XbmcBackup:
|
|||||||
def _checkCancel(self):
|
def _checkCancel(self):
|
||||||
result = False
|
result = False
|
||||||
|
|
||||||
if(self.progressBar != None):
|
if(self.progressBar != None and type(self.progressBar) is xbmcgui.DialogProgress):
|
||||||
result = self.progressBar.iscanceled()
|
result = self.progressBar.iscanceled()
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import xbmc
|
import xbmc
|
||||||
|
import xbmcgui
|
||||||
import xbmcaddon
|
import xbmcaddon
|
||||||
|
|
||||||
__addon_id__= 'script.xbmcbackup'
|
__addon_id__= 'script.xbmcbackup'
|
||||||
@ -17,7 +18,7 @@ def log(message,loglevel=xbmc.LOGNOTICE):
|
|||||||
xbmc.log(encode(__addon_id__ + "-" + __Addon.getAddonInfo('version') + ": " + message),level=loglevel)
|
xbmc.log(encode(__addon_id__ + "-" + __Addon.getAddonInfo('version') + ": " + message),level=loglevel)
|
||||||
|
|
||||||
def showNotification(message):
|
def showNotification(message):
|
||||||
xbmc.executebuiltin("Notification(" + encode(getString(30010)) + "," + encode(message) + ",4000," + xbmc.translatePath(__Addon.getAddonInfo('path') + "/icon.png") + ")")
|
xbmcgui.Dialog().notification(encode(getString(30010)),encode(message),time=4000,icon=xbmc.translatePath(__Addon.getAddonInfo('path') + "/icon.png"))
|
||||||
|
|
||||||
def getSetting(name):
|
def getSetting(name):
|
||||||
return __Addon.getSetting(name)
|
return __Addon.getSetting(name)
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<setting id="dropbox_key" type="text" label="30028" visible="eq(-3,2)" default="" />
|
<setting id="dropbox_key" type="text" label="30028" visible="eq(-3,2)" default="" />
|
||||||
<setting id="dropbox_secret" type="text" label="30029" visible="eq(-4,2)" default="" />
|
<setting id="dropbox_secret" type="text" label="30029" visible="eq(-4,2)" default="" />
|
||||||
<setting id="backup_rotation" type="number" label="30026" default="0" />
|
<setting id="backup_rotation" type="number" label="30026" default="0" />
|
||||||
<setting id="run_silent" type="bool" label="30022" default="false" />
|
<setting id="progress_mode" type="enum" label="30022" lvalues="30082|30083|30084" default="0" />
|
||||||
</category>
|
</category>
|
||||||
<category id="selection" label="30012">
|
<category id="selection" label="30012">
|
||||||
<setting id="backup_addons" type="bool" label="30030" default="true" />
|
<setting id="backup_addons" type="bool" label="30030" default="true" />
|
||||||
|
12
scheduler.py
12
scheduler.py
@ -25,7 +25,6 @@ class BackupScheduler:
|
|||||||
#scheduler was turned on, find next run time
|
#scheduler was turned on, find next run time
|
||||||
utils.log("scheduler enabled, finding next run time")
|
utils.log("scheduler enabled, finding next run time")
|
||||||
self.findNextRun(time.time())
|
self.findNextRun(time.time())
|
||||||
utils.log("scheduler will run again on " + datetime.datetime.fromtimestamp(self.next_run).strftime('%m-%d-%Y %H:%M'))
|
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
|
|
||||||
@ -46,13 +45,18 @@ class BackupScheduler:
|
|||||||
now = time.time()
|
now = time.time()
|
||||||
|
|
||||||
if(self.next_run <= now):
|
if(self.next_run <= now):
|
||||||
if(utils.getSetting('run_silent') == 'false'):
|
progress_mode = int(utils.getSetting('progress_mode'))
|
||||||
|
if(progress_mode != 2):
|
||||||
utils.showNotification(utils.getString(30053))
|
utils.showNotification(utils.getString(30053))
|
||||||
#run the job in backup mode, hiding the dialog box
|
|
||||||
backup = XbmcBackup()
|
backup = XbmcBackup()
|
||||||
|
|
||||||
if(backup.remoteConfigured()):
|
if(backup.remoteConfigured()):
|
||||||
backup.run(XbmcBackup.Backup,True)
|
|
||||||
|
if(int(utils.getSetting('progress_mode')) in [0,1]):
|
||||||
|
backup.run(XbmcBackup.Backup,True)
|
||||||
|
else:
|
||||||
|
backup.run(XbmcBackup.Backup,False)
|
||||||
|
|
||||||
#check if this is a "one-off"
|
#check if this is a "one-off"
|
||||||
if(int(utils.getSetting("schedule_interval")) == 0):
|
if(int(utils.getSetting("schedule_interval")) == 0):
|
||||||
|
Loading…
Reference in New Issue
Block a user