mirror of
https://github.com/robweber/xbmcbackup.git
synced 2024-11-15 04:45:49 +01:00
commit
f2d61ed19d
14
README.txt
14
README.txt
@ -13,6 +13,8 @@ Scheduling:
|
|||||||
|
|
||||||
You can also schedule backups to be completed on a set interval via the scheduling area. When it is time for the backup to run it will be executed in the background.
|
You can also schedule backups to be completed on a set interval via the scheduling area. When it is time for the backup to run it will be executed in the background.
|
||||||
|
|
||||||
|
When using the "Shutdown" function this will call XBMC's Shutdown method as defined in System Settings -> Power Saving -> Shutdown Function. This can be simply exiting xbmc, hibernating, or shutting down your htpc.
|
||||||
|
|
||||||
Running the Program:
|
Running the Program:
|
||||||
|
|
||||||
Running the program will allow you to select Backup or Restore as a running mode. Selecting Backup will push files to your remote store using the addon settings you defined. Selecting Restore will give you a list of restore points currently in your remote destination. Selecting one will pull the files matching your selection criteria from the restore point to your local XBMC folders.
|
Running the program will allow you to select Backup or Restore as a running mode. Selecting Backup will push files to your remote store using the addon settings you defined. Selecting Restore will give you a list of restore points currently in your remote destination. Selecting one will pull the files matching your selection criteria from the restore point to your local XBMC folders.
|
||||||
@ -20,7 +22,17 @@ Running the program will allow you to select Backup or Restore as a running mode
|
|||||||
|
|
||||||
Using Dropbox:
|
Using Dropbox:
|
||||||
|
|
||||||
Using Dropbox as a storage target adds a few steps the first time you wish to run a backup. XBMC Backup needs to have permission to access your Dropbox account. When you see the prompt regarding the Dropbox URL Authorization DO NOT click OK. Check your XBMC log file for a line from "script.xbmcbackup" containing the authorization URL. Cut/paste this into a browser and click Allow. Once this is done you can click "OK" in XBMC and proceed as normal. XBMC Backup will cache the authorization code so you only have to do this once, or if you revoke the Dropbox permissions.
|
Using Dropbox as a storage target adds a few steps the first time you wish to run a backup. First you will need to sign-up for you own developer app key and secret by visiting https://www.dropbox.com/developers. Name your app whatevery you want, and make it an "App Folder" type application. Your app can run in developer mode and you should never need to apply for production status. This is to get around Dropbox's rule not allow distribution of production key/secret pairs.
|
||||||
|
|
||||||
|
Once you have your app key and secret add them to the settings. XBMC Backup now needs to have permission to access your Dropbox account. When you see the prompt regarding the Dropbox URL Authorization DO NOT click OK. Check your XBMC log file for a line from "script.xbmcbackup" containing the authorization URL. Cut/paste this into a browser and click Allow. Once this is done you can click "OK" in XBMC and proceed as normal. XBMC Backup will cache the authorization code so you only have to do this once, or if you revoke the Dropbox permissions.
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
||||||
|
|
||||||
|
RunScript(script.xbmcbackup,backup)
|
||||||
|
|
||||||
|
|
||||||
What this Addon Will Not Do:
|
What this Addon Will Not Do:
|
||||||
|
|
||||||
|
@ -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.3.1" provider-name="robweber">
|
name="XBMC Backup" version="0.3.4" provider-name="robweber">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="2.0"/>
|
<import addon="xbmc.python" version="2.1.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,7 +1,23 @@
|
|||||||
|
Version 0.3.4
|
||||||
|
|
||||||
|
added ability to take parameters via RunScript() or JSONRPC.Addons.ExecuteAddon()
|
||||||
|
|
||||||
|
Version 0.3.3
|
||||||
|
|
||||||
|
updated xbmc python version (2.1.0)
|
||||||
|
|
||||||
|
Version 0.3.2
|
||||||
|
|
||||||
|
added settings for user provided Dropbox key and secret
|
||||||
|
|
||||||
Version 0.3.1
|
Version 0.3.1
|
||||||
|
|
||||||
added try/except for multiple character encodings
|
added try/except for multiple character encodings
|
||||||
|
|
||||||
|
remove token.txt file if Dropbox Authorization is revoked
|
||||||
|
|
||||||
|
can shutdown xbmc after scheduled backup
|
||||||
|
|
||||||
Version 0.3.0
|
Version 0.3.0
|
||||||
|
|
||||||
major vfs rewrite
|
major vfs rewrite
|
||||||
|
15
default.py
15
default.py
@ -2,8 +2,19 @@ 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
|
||||||
|
|
||||||
#figure out if this is a backup or a restore
|
#the program mode
|
||||||
mode = xbmcgui.Dialog().select(utils.getString(30010) + " - " + utils.getString(30023),[utils.getString(30016),utils.getString(30017)])
|
mode = -1
|
||||||
|
|
||||||
|
#check if mode was passed in as an argument
|
||||||
|
if(len(sys.argv) > 1):
|
||||||
|
if(sys.argv[1].lower() == 'backup'):
|
||||||
|
mode = 0
|
||||||
|
elif(sys.argv[1].lower() == 'restore'):
|
||||||
|
mode = 1
|
||||||
|
|
||||||
|
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)])
|
||||||
|
|
||||||
if(mode != -1):
|
if(mode != -1):
|
||||||
#run the profile backup
|
#run the profile backup
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
<string id="30025">Remote Path Type</string>
|
<string id="30025">Remote Path Type</string>
|
||||||
<string id="30026">Backups to keep (0 for all)</string>
|
<string id="30026">Backups to keep (0 for all)</string>
|
||||||
<string id="30027">Dropbox</string>
|
<string id="30027">Dropbox</string>
|
||||||
|
<string id="30028">Dropbox Key</string>
|
||||||
|
<string id="30029">Dropbox Secret</string>
|
||||||
|
|
||||||
<string id="30030">User Addons</string>
|
<string id="30030">User Addons</string>
|
||||||
<string id="30031">Addon Data</string>
|
<string id="30031">Addon Data</string>
|
||||||
@ -37,6 +39,8 @@
|
|||||||
<string id="30054">Removing backup</string>
|
<string id="30054">Removing backup</string>
|
||||||
<string id="30056">Check log for Dropbox authorize URL</string>
|
<string id="30056">Check log for Dropbox authorize URL</string>
|
||||||
<string id="30057">Click OK when authorized</string>
|
<string id="30057">Click OK when authorized</string>
|
||||||
|
<string id="30058">Dropbox Developer Code Needed</string>
|
||||||
|
<string id="30059">Visit https://www.dropbox.com/developers</string>
|
||||||
|
|
||||||
<string id="30060">Enable Scheduler</string>
|
<string id="30060">Enable Scheduler</string>
|
||||||
<string id="30061">Schedule</string>
|
<string id="30061">Schedule</string>
|
||||||
@ -54,4 +58,5 @@
|
|||||||
<string id="30073">Every Week</string>
|
<string id="30073">Every Week</string>
|
||||||
<string id="30074">First Day of Month</string>
|
<string id="30074">First Day of Month</string>
|
||||||
<string id="30075">Custom Schedule</string>
|
<string id="30075">Custom Schedule</string>
|
||||||
|
<string id="30076">Shutdown After Backup</string>
|
||||||
</strings>
|
</strings>
|
||||||
|
@ -5,8 +5,8 @@ import xbmcgui
|
|||||||
import sys
|
import sys
|
||||||
from dropbox import client, rest, session
|
from dropbox import client, rest, session
|
||||||
|
|
||||||
APP_KEY = 'f5wlmek6aoriqax'
|
APP_KEY = utils.getSetting('dropbox_key')
|
||||||
APP_SECRET = 'b1461sje1kxgzet'
|
APP_SECRET = utils.getSetting('dropbox_secret')
|
||||||
|
|
||||||
class Vfs:
|
class Vfs:
|
||||||
root_path = None
|
root_path = None
|
||||||
@ -64,6 +64,10 @@ class DropboxFileSystem(Vfs):
|
|||||||
client = None
|
client = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
if(APP_KEY == '' or APP_SECRET == ''):
|
||||||
|
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30058),utils.getString(30059))
|
||||||
|
return
|
||||||
|
|
||||||
user_token_key,user_token_secret = self.getToken()
|
user_token_key,user_token_secret = self.getToken()
|
||||||
|
|
||||||
sess = session.DropboxSession(APP_KEY,APP_SECRET,"app_folder")
|
sess = session.DropboxSession(APP_KEY,APP_SECRET,"app_folder")
|
||||||
@ -84,7 +88,13 @@ class DropboxFileSystem(Vfs):
|
|||||||
sess.set_token(user_token_key,user_token_secret)
|
sess.set_token(user_token_key,user_token_secret)
|
||||||
|
|
||||||
self.client = client.DropboxClient(sess)
|
self.client = client.DropboxClient(sess)
|
||||||
|
|
||||||
|
try:
|
||||||
utils.log(str(self.client.account_info()))
|
utils.log(str(self.client.account_info()))
|
||||||
|
except:
|
||||||
|
#this didn't work, delete the token file
|
||||||
|
self.deleteToken()
|
||||||
|
|
||||||
|
|
||||||
def listdir(self,directory):
|
def listdir(self,directory):
|
||||||
if(self.client != None and self.exists(directory)):
|
if(self.client != None and self.exists(directory)):
|
||||||
@ -150,6 +160,7 @@ class DropboxFileSystem(Vfs):
|
|||||||
out.close()
|
out.close()
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def setToken(self,key,secret):
|
def setToken(self,key,secret):
|
||||||
#write the token files
|
#write the token files
|
||||||
token_file = open(xbmc.translatePath(utils.data_dir() + "tokens.txt"),'w')
|
token_file = open(xbmc.translatePath(utils.data_dir() + "tokens.txt"),'w')
|
||||||
@ -167,6 +178,10 @@ class DropboxFileSystem(Vfs):
|
|||||||
else:
|
else:
|
||||||
return ["",""]
|
return ["",""]
|
||||||
|
|
||||||
|
def deleteToken(self):
|
||||||
|
if(xbmcvfs.exists(xbmc.translatePath(utils.data_dir() + "tokens.txt"))):
|
||||||
|
xbmcvfs.delete(xbmc.translatePath(utils.data_dir() + "tokens.txt"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
<setting id="remote_selection" type="enum" lvalues="30018|30019|30027" default="0" label="30025"/>
|
<setting id="remote_selection" type="enum" lvalues="30018|30019|30027" default="0" label="30025"/>
|
||||||
<setting id="remote_path_2" type="text" label="30024" default="" visible="eq(-1,1)" />
|
<setting id="remote_path_2" type="text" label="30024" default="" visible="eq(-1,1)" />
|
||||||
<setting id="remote_path" type="folder" label="30020" visible="eq(-2,0)" />
|
<setting id="remote_path" type="folder" label="30020" visible="eq(-2,0)" />
|
||||||
|
<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="backup_rotation" type="number" label="30026" default="0" />
|
||||||
<setting id="run_silent" type="bool" label="30022" default="false" />
|
<setting id="run_silent" type="bool" label="30022" default="false" />
|
||||||
</category>
|
</category>
|
||||||
@ -22,5 +24,6 @@
|
|||||||
<setting id="schedule_time" type="labelenum" label="30062" values="00:00|01:00|02:00|03:00|04:00|05:00|06:00|07:00|08:00|09:00|10:00|11:00|12:00|13:00|14:00|15:00|16:00|17:00|18:00|19:00|20:00|21:00|22:00|23:00" default="00:00" visible="!eq(-1,3)" enable="eq(-2,true)"/>
|
<setting id="schedule_time" type="labelenum" label="30062" values="00:00|01:00|02:00|03:00|04:00|05:00|06:00|07:00|08:00|09:00|10:00|11:00|12:00|13:00|14:00|15:00|16:00|17:00|18:00|19:00|20:00|21:00|22:00|23:00" default="00:00" visible="!eq(-1,3)" enable="eq(-2,true)"/>
|
||||||
<setting id="day_of_week" type="enum" label="30063" lvalues="30065|30066|30067|30068|30069|30070|30071" default="0" visible="eq(-2,1)" enable="eq(-3,true)"/>
|
<setting id="day_of_week" type="enum" label="30063" lvalues="30065|30066|30067|30068|30069|30070|30071" default="0" visible="eq(-2,1)" enable="eq(-3,true)"/>
|
||||||
<setting id="cron_schedule" type="text" label="30064" default="0 0 * * *" visible="eq(-3,3)" enable="eq(-4,true)"/>
|
<setting id="cron_schedule" type="text" label="30064" default="0 0 * * *" visible="eq(-3,3)" enable="eq(-4,true)"/>
|
||||||
|
<setting id="cron_shutdown" type="bool" label="30076" default="false" enable="eq(-5,true)" />
|
||||||
</category>
|
</category>
|
||||||
</settings>
|
</settings>
|
||||||
|
@ -44,6 +44,14 @@ class BackupScheduler:
|
|||||||
#run the job in backup mode, hiding the dialog box
|
#run the job in backup mode, hiding the dialog box
|
||||||
backup = XbmcBackup()
|
backup = XbmcBackup()
|
||||||
backup.run(XbmcBackup.Backup,True)
|
backup.run(XbmcBackup.Backup,True)
|
||||||
|
|
||||||
|
#check if we should shut the computer down
|
||||||
|
if(utils.getSetting("cron_shutdown") == 'true'):
|
||||||
|
#wait 10 seconds to make sure all backup processes and files are completed
|
||||||
|
time.sleep(10)
|
||||||
|
xbmc.executebuiltin('ShutDown()')
|
||||||
|
else:
|
||||||
|
#find the next run time like normal
|
||||||
self.findNextRun(now,True)
|
self.findNextRun(now,True)
|
||||||
else:
|
else:
|
||||||
self.findNextRun(now)
|
self.findNextRun(now)
|
||||||
@ -82,7 +90,6 @@ class BackupScheduler:
|
|||||||
hour_of_day = int(hour_of_day[0:2])
|
hour_of_day = int(hour_of_day[0:2])
|
||||||
if(schedule_type == 0):
|
if(schedule_type == 0):
|
||||||
#every day
|
#every day
|
||||||
|
|
||||||
cron_exp = "0 " + str(hour_of_day) + " * * *"
|
cron_exp = "0 " + str(hour_of_day) + " * * *"
|
||||||
elif(schedule_type == 1):
|
elif(schedule_type == 1):
|
||||||
#once a week
|
#once a week
|
||||||
|
Loading…
Reference in New Issue
Block a user