diff --git a/README.txt b/README.txt index 3c8679d..750f69b 100644 --- a/README.txt +++ b/README.txt @@ -5,15 +5,15 @@ I've had to recover my database, thumbnails, and source configuration enough tim 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. -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: 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. diff --git a/changelog.txt b/changelog.txt index adcab57..79c42fe 100644 --- a/changelog.txt +++ b/changelog.txt @@ -56,3 +56,5 @@ removed need for separate verbose logging setting updated utf-8 encoding for all logging +backup now uses date as folder name, restore allows user to type date of last backup + diff --git a/default.py b/default.py index e7491da..bf88686 100644 --- a/default.py +++ b/default.py @@ -3,6 +3,7 @@ import xbmcaddon import xbmcgui import resources.lib.vfs as vfs import os +import time __addon_id__ = 'script.xbmcbackup' __Addon = xbmcaddon.Addon(__addon_id__) @@ -102,8 +103,16 @@ class XbmcBackup: self.addon.setSetting("remote_path","") elif(self.addon.getSetting('remote_selection') == '0'): 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") + "/" else: self.remote_path = "" @@ -121,16 +130,24 @@ class XbmcBackup: #check what mode were are in if(int(self.addon.getSetting('addon_mode')) == 0): 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() else: 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): - if(vfs.exists(self.remote_path)): - #this will fail - need a disclaimer here - log(self.addon.getLocalizedString(30050)) - + #make the remote directory vfs.mkdir(self.remote_path) diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 43d1560..b88f105 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -22,7 +22,7 @@ Thumbnails/Fanart Config Files - Error: Remote path cannot be empty + Error: Remote path doesn't exist Starting Local Dir Remote Dir diff --git a/resources/language/French/strings.xml b/resources/language/French/strings.xml index e06365d..1ffc3cc 100644 --- a/resources/language/French/strings.xml +++ b/resources/language/French/strings.xml @@ -22,7 +22,7 @@ Miniatures / Fanart Fichiers de configuration - Erreur : Le chemin distant ne peut pas être vide. + Erreur : chemin distant n'existe pas Démarrage Dossier Local Dossier Distant diff --git a/resources/settings.xml b/resources/settings.xml index 8f2e9db..d6cad5a 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -5,7 +5,7 @@ - +