changed backup behavior, all backups now create dated folder within backup location

restore operation now prompts for the date of the backup you wish to restore from
This commit is contained in:
robweber 2012-08-17 14:59:47 -05:00
parent 26c99723bf
commit 1e5a524ae3
6 changed files with 32 additions and 13 deletions

View File

@ -5,15 +5,15 @@ I've had to recover my database, thumbnails, and source configuration enough tim
Usage: Usage:
In the addon settings you can define a remote path for the destination of your xbmc files. You must also include a backup folder name, all of your files will be in this folder once the backup runs. 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 month, day, year format so you can create multiple backups.
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.
To restore your data simply switch the Mode from "backup" to "restore" and the files will be copied from your remote directory to the local path. The file selection criteria will be used for the restore as well. To restore your data simply switch the Mode from "backup" to "restore" and type the date of the backup you wish to restore from . The files will be copied from your remote directory to the local path. The file selection criteria will be used for the restore as well.
What this Addon Will Not Do: What this Addon Will Not Do:
This is not meant as an XBMC file sync solution. If you have multiple frontends you want to keep in sync this addon may work in a "poor man's" sort of way but it is not intended for that. This is not meant as an XBMC file sync solution. If you have multiple frontends you want to keep in sync this addon may work in a "poor man's" sort of way but it is not intended for that.
Your remote folder will not be "pruned" of files you have deleted. This behavior may change in the future but right now it is up to you to remove obsolete items from the remote path. The easiest way is to just delete the remote folder before doing a full backup. This backup will not check the backup destination and delete files that do not match. It is best to only do one backup per day so that each folder is correct.

View File

@ -56,3 +56,5 @@ removed need for separate verbose logging setting
updated utf-8 encoding for all logging updated utf-8 encoding for all logging
backup now uses date as folder name, restore allows user to type date of last backup

View File

@ -3,6 +3,7 @@ import xbmcaddon
import xbmcgui import xbmcgui
import resources.lib.vfs as vfs import resources.lib.vfs as vfs
import os import os
import time
__addon_id__ = 'script.xbmcbackup' __addon_id__ = 'script.xbmcbackup'
__Addon = xbmcaddon.Addon(__addon_id__) __Addon = xbmcaddon.Addon(__addon_id__)
@ -103,7 +104,15 @@ class XbmcBackup:
elif(self.addon.getSetting('remote_selection') == '0'): elif(self.addon.getSetting('remote_selection') == '0'):
self.remote_path = self.addon.getSetting("remote_path") self.remote_path = self.addon.getSetting("remote_path")
if(self.addon.getSetting("backup_name") != '' and self.remote_path != ''): #check if trailing slash is included
if(self.remote_path[-1:] != "/"):
self.remote_path = self.remote_path + "/"
#append backup folder name
if(int(self.addon.getSetting('addon_mode')) == 0 and self.remote_path != ''):
date_today = time.localtime(time.time())
self.remote_path = self.remote_path + str(date_today[1]) + str(date_today[2]) + str(date_today[0]) + "/"
elif(int(self.addon.getSetting('addon_mode')) == 1 and self.addon.getSetting("backup_name") != '' and self.remote_path != ''):
self.remote_path = self.remote_path + self.addon.getSetting("backup_name") + "/" self.remote_path = self.remote_path + self.addon.getSetting("backup_name") + "/"
else: else:
self.remote_path = "" self.remote_path = ""
@ -121,15 +130,23 @@ class XbmcBackup:
#check what mode were are in #check what mode were are in
if(int(self.addon.getSetting('addon_mode')) == 0): if(int(self.addon.getSetting('addon_mode')) == 0):
self.fileManager = FileManager(self.local_path,self.addon.getAddonInfo('profile')) self.fileManager = FileManager(self.local_path,self.addon.getAddonInfo('profile'))
#for backups check if remote path exists
if(vfs.exists(self.remote_path)):
#this will fail - need a disclaimer here
log(self.addon.getLocalizedString(30050))
self.syncFiles() self.syncFiles()
else: else:
self.fileManager = FileManager(self.remote_path,self.addon.getAddonInfo('profile')) self.fileManager = FileManager(self.remote_path,self.addon.getAddonInfo('profile'))
self.restoreFiles()
#for restores remote path must exist
if(vfs.exists(self.remote_path)):
self.restoreFiles()
else:
xbmcgui.Dialog().ok(self.addon.getLocalizedString(30010),self.addon.getLocalizedString(30045))
def syncFiles(self): def syncFiles(self):
if(vfs.exists(self.remote_path)):
#this will fail - need a disclaimer here
log(self.addon.getLocalizedString(30050))
#make the remote directory #make the remote directory
vfs.mkdir(self.remote_path) vfs.mkdir(self.remote_path)

View File

@ -22,7 +22,7 @@
<string id="30034">Thumbnails/Fanart</string> <string id="30034">Thumbnails/Fanart</string>
<string id="30035">Config Files</string> <string id="30035">Config Files</string>
<string id="30045">Error: Remote path cannot be empty</string> <string id="30045">Error: Remote path doesn't exist</string>
<string id="30046">Starting</string> <string id="30046">Starting</string>
<string id="30047">Local Dir</string> <string id="30047">Local Dir</string>
<string id="30048">Remote Dir</string> <string id="30048">Remote Dir</string>

View File

@ -22,7 +22,7 @@
<string id="30034">Miniatures / Fanart</string> <string id="30034">Miniatures / Fanart</string>
<string id="30035">Fichiers de configuration</string> <string id="30035">Fichiers de configuration</string>
<string id="30045">Erreur : Le chemin distant ne peut pas être vide.</string> <string id="30045">Erreur : chemin distant n'existe pas</string>
<string id="30046">Démarrage</string> <string id="30046">Démarrage</string>
<string id="30047">Dossier Local</string> <string id="30047">Dossier Local</string>
<string id="30048">Dossier Distant</string> <string id="30048">Dossier Distant</string>

View File

@ -5,7 +5,7 @@
<setting id="remote_selection" type="enum" lvalues="30018|30019" default="0" label="30025"/> <setting id="remote_selection" type="enum" lvalues="30018|30019" 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="backup_name" type="text" label="30021" default="xbmc_backup"/> <setting id="backup_name" type="text" label="30021" default="backup_date" visible="eq(-4,1)"/>
<setting id="run_silent" type="bool" label="30022" default="false" /> <setting id="run_silent" type="bool" label="30022" default="false" />
</category> </category>
<category id="selection" label="30012"> <category id="selection" label="30012">