mirror of
https://github.com/robweber/xbmcbackup.git
synced 2024-11-15 04:45:49 +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:
|
||||
|
||||
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.
|
||||
|
||||
@ -37,11 +37,38 @@ Once you have your app key and secret add them to the settings. XBMC Backup now
|
||||
|
||||
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:
|
||||
|
||||
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"?>
|
||||
<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>
|
||||
<import addon="xbmc.python" version="2.1.0"/>
|
||||
<import addon="xbmc.python" version="2.12.0"/>
|
||||
</requires>
|
||||
<extension point="xbmc.python.script" library="default.py">
|
||||
<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
|
||||
|
||||
|
43
default.py
43
default.py
@ -1,21 +1,37 @@
|
||||
import urlparse
|
||||
import xbmcgui
|
||||
import resources.lib.utils as utils
|
||||
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
|
||||
mode = -1
|
||||
params = get_params()
|
||||
|
||||
#check if mode was passed in as an argument
|
||||
if(len(sys.argv) > 1):
|
||||
if(sys.argv[1].lower() == 'backup'):
|
||||
|
||||
if("mode" in params):
|
||||
if(params['mode'] == 'backup'):
|
||||
mode = 0
|
||||
elif(sys.argv[1].lower() == 'restore'):
|
||||
elif(params['mode'] == 'restore'):
|
||||
mode = 1
|
||||
|
||||
#if mode wasn't passed in as arg, get from user
|
||||
if(mode == -1):
|
||||
#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)])
|
||||
|
||||
#check if program should be run
|
||||
if(mode != -1):
|
||||
#run the profile backup
|
||||
backup = XbmcBackup()
|
||||
@ -23,14 +39,29 @@ if(mode != -1):
|
||||
if(backup.remoteConfigured()):
|
||||
|
||||
if(mode == backup.Restore):
|
||||
#allow user to select the backup to restore from
|
||||
#get list of valid restore points
|
||||
restorePoints = backup.listBackups()
|
||||
pointNames = []
|
||||
folderNames = []
|
||||
|
||||
for aDir in restorePoints:
|
||||
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):
|
||||
backup.selectRestore(restorePoints[selectedRestore][0])
|
||||
|
@ -14,7 +14,7 @@
|
||||
<string id="30019">Въвеждане на път</string>
|
||||
<string id="30020">Прегледайте</string>
|
||||
<string id="30021">Име на папката за резервните копия</string>
|
||||
<string id="30022">Изпълнявай "тихо"</string>
|
||||
<string id="30022">Известяване за напредъка</string>
|
||||
<string id="30023">Режим</string>
|
||||
<string id="30024">Въведете отдалечения път</string>
|
||||
<string id="30025">Окажете пътя до папката с резервни копия</string>
|
||||
@ -73,4 +73,7 @@
|
||||
<string id="30079">Само днес</string>
|
||||
<string id="30080">Профили</string>
|
||||
<string id="30081">Планировчика ще стартира отново на</string>
|
||||
<string id="30082">Лента за напредъка</string>
|
||||
<string id="30083">Лента за напредъка на заден план</string>
|
||||
<string id="30084">Без (тих режим)</string>
|
||||
</strings>
|
||||
|
@ -14,7 +14,7 @@
|
||||
<string id="30019">Type Path</string>
|
||||
<string id="30020">Browse Remote Path</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="30024">Type Remote Path</string>
|
||||
<string id="30025">Remote Path Type</string>
|
||||
@ -73,4 +73,7 @@
|
||||
<string id="30079">Just Today</string>
|
||||
<string id="30080">Profiles</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>
|
||||
|
@ -89,7 +89,11 @@ class XbmcBackup:
|
||||
def skipAdvanced(self):
|
||||
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
|
||||
progressBarTitle = utils.getString(30010) + " - "
|
||||
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)
|
||||
|
||||
#check if we should use the progress bar
|
||||
if(utils.getSetting('run_silent') == 'false' and not runSilent):
|
||||
self.progressBar = xbmcgui.DialogProgress()
|
||||
if(int(utils.getSetting('progress_mode')) != 2):
|
||||
#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) + "......")
|
||||
|
||||
if(mode == self.Backup):
|
||||
@ -315,9 +324,12 @@ class XbmcBackup:
|
||||
#call update addons to refresh everything
|
||||
xbmc.executebuiltin('UpdateLocalAddons')
|
||||
|
||||
if(utils.getSetting('run_silent') == 'false' and not runSilent):
|
||||
if(self.progressBar != None):
|
||||
self.progressBar.close()
|
||||
|
||||
#reset the window setting
|
||||
window.setProperty(utils.__addon_id__ + ".running","")
|
||||
|
||||
def backupFiles(self,fileList,source,dest):
|
||||
utils.log("Writing files to: " + dest.root_path)
|
||||
utils.log("Source: " + source.root_path)
|
||||
@ -361,7 +373,7 @@ class XbmcBackup:
|
||||
def _checkCancel(self):
|
||||
result = False
|
||||
|
||||
if(self.progressBar != None):
|
||||
if(self.progressBar != None and type(self.progressBar) is xbmcgui.DialogProgress):
|
||||
result = self.progressBar.iscanceled()
|
||||
|
||||
return result
|
||||
|
@ -1,4 +1,5 @@
|
||||
import xbmc
|
||||
import xbmcgui
|
||||
import xbmcaddon
|
||||
|
||||
__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)
|
||||
|
||||
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):
|
||||
return __Addon.getSetting(name)
|
||||
|
@ -7,7 +7,7 @@
|
||||
<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="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 id="selection" label="30012">
|
||||
<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
|
||||
utils.log("scheduler enabled, finding next run 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):
|
||||
|
||||
@ -46,13 +45,18 @@ class BackupScheduler:
|
||||
now = time.time()
|
||||
|
||||
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))
|
||||
#run the job in backup mode, hiding the dialog box
|
||||
|
||||
backup = XbmcBackup()
|
||||
|
||||
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"
|
||||
if(int(utils.getSetting("schedule_interval")) == 0):
|
||||
|
Loading…
Reference in New Issue
Block a user