Kodi Community Forum
[Release] Backup (formerly XBMC Backup) - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Program Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=151)
+---- Thread: [Release] Backup (formerly XBMC Backup) (/showthread.php?tid=129499)



RE: [Release] XBMC Backup - Allram - 2014-11-10

Hi
Used bacup function when changed from Gotham to helix,,, worked great.

Now when i try to backup from helix the folder creats with subfolders "Addon and Userdata" and file called xbmcbackup.val

But there is no files backuped inside them?
Suggestions would be much appreciated.

Had this problem both under beta 1 and now with Beta 2.

Tnx in advance

Magnus


RE: [Release] XBMC Backup - robweber - 2014-11-10




RE: [Release] XBMC Backup - McButton - 2014-11-11

Im using OpenElec & Nox. I've tried the backup a few times to no avail. I get in Putty and have this error:


OpenELEC:~ # kill all -9 xbmc.bin
sh: invalid number 'all'
sh: can't kill pid -9: No such process
sh: invalid number 'xbmc.bin'

Is there not an easier way to backup everything? Openelec has a backup, but I can't seem to get that going either. I've had to restore xbmc like 12 times, and I always have to manually add all my skin info again. Sad
----------------------------------
I figured it out is "killall" ...should get the FAQ updated for that one. Smile
I tried it, the box reset. Copied my file, and notta. Same screen. I assume I have to reset the box after my copy, but nothing happened. I checked and only see a few settings that even restored. ...shoot... When the screen goes BLACK, should is stay that way? Mine just resets after 5 seconds.


RE: [Release] XBMC Backup - robweber - 2014-11-11

The only reason to use that command is to attempt restoring your guisettings file. I'm going to assume that is what you are trying to do.

You are correct that the FAQ on the first post of this thread is wrong. Openelec changed the command. You can find it in the updated FAQ in the readme file. I'll update the forum later. The screen should go black as you are killing xbmc.

https://github.com/robweber/xbmcbackup/blob/master/README.txt


RE: [Release] XBMC Backup - McButton - 2014-11-11

Yeah. Restoring the GUI. I don't know what else would need a restore. The GUI has all the cool stuff! Is there a way to keep it black longer? I actually just hit ENTER on Putty and pasted in WinSCP at the same time, and it refreshed updated.
I dislike this, but I'm glad there is a solution at least. Hopefully, there will be an easier way some day Smile

I'll dig through the link you posted. I don't know a ton about programming nor do I want to mess with it all the time. XBMC is def forcing me to embrace it though. There's so many things I've had to customize in skin codes to get everything to work. Gotta work to get what you want, I suppose.

Thanks so much for this!


RE: [Release] XBMC Backup - robweber - 2014-11-11

I agree that the solution for the guisettings file is not ideal. It has the most "front facing" information in it for the user yet is the hardest to restore as you can't just do a straight file-copy while xbmc is running and expect it to work.

When using the newer "systemctl stop xbmc.service" command in OpenElec the screen should stay black until you issue the start command. If this isn't happening perhaps it's an OpenElec issue.


RE: [Release] XBMC Backup - andisa - 2014-11-12

Does XBMC Backup work for anyone with Kodi 14.0 beta1&2?


RE: [Release] XBMC Backup - jenoyend - 2014-11-13

Hello, I succeed in what I wanted to do, run a script during the backup and the restore part.

I had an issue because the script were on my Hard drive.
Even with a chmod 777, I was not able to run it.
So I first copy the script in a temp folder, then run it and delete the temp folder.
I succeed to run a shell script but not a python script.

In backup.py
Quote:import os
import shutil
import subprocess
...
#check if there is a custom script to run while saving
if(utils.getSetting('custom_script_save_enable') == 'true' and utils.getSetting('backup_custom_script_save_enable') != ''):

if(not os.path.exists(utils.getSetting('backup_custom_script_save_enable'))):
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30045),utils.getSetting('backup_custom_script_save_enable'))
return
else:
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30102),utils.getSetting('backup_custom_script_save_enable'))
current_path=os.path.dirname(os.path.abspath(__file__))
basename=os.path.basename(utils.getSetting('backup_custom_script_save_enable'))
temp_folder=os.path.join(current_path,'_temp')
temp_script_path=os.path.join(temp_folder,basename)
if not os.path.isdir(temp_folder):
os.mkdir(temp_folder)
shutil.copy(utils.getSetting('backup_custom_script_save_enable'),temp_script_path)
_err=subprocess.call(temp_script_path, shell=True)
if _err!=0:
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30104),utils.getSetting('backup_custom_script_save_enable'))
else:
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30105),utils.getSetting('backup_custom_script_save_enable'))
shutil.rmtree(temp_folder,ignore_errors=True)
else:
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30103),temp_folder)

...
#check if there is a custom script to run while restoring
if(utils.getSetting('custom_script_restore_enable') == 'true' and utils.getSetting('backup_custom_script_restore_enable') != ''):

if(not os.path.exists(utils.getSetting('backup_custom_script_restore_enable'))):
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30045),utils.getSetting('backup_custom_script_restore_enable'))
return
else:
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30102),utils.getSetting('backup_custom_script_restore_enable'))
current_path=os.path.dirname(os.path.abspath(__file__))
basename=os.path.basename(utils.getSetting('backup_custom_script_restore_enable'))
temp_folder=os.path.join(current_path,'_temp')
temp_script_path=os.path.join(temp_folder,basename)
if not os.path.isdir(temp_folder):
os.mkdir(temp_folder)
shutil.copy(utils.getSetting('backup_custom_script_restore_enable'),temp_script_path)
_err=subprocess.call(temp_script_path, shell=True)
if _err!=0:
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30104),utils.getSetting('backup_custom_script_restore_enable'))
else:
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30105),utils.getSetting('backup_custom_script_restore_enable'))
shutil.rmtree(temp_folder,ignore_errors=True)
else:
xbmcgui.Dialog().ok(utils.getString(30010),utils.getString(30103),temp_folder)

In settings.xml:
Quote: <category id="selection" label="30012">
<setting id="custom_script_save_enable" type="bool" label="30100" default="false" />
<setting id="backup_custom_script_save_enable" type="file" label="30018" default="" visible="eq(-1,true)"/>
<setting id="custom_script_restore_enable" type="bool" label="30101" default="false" />
<setting id="backup_custom_script_restore_enable" type="file" label="30018" default="" visible="eq(-1,true)"/>

I had to change the label because there are differences between the french and the english file: strings.xml

In strings.xml:
Quote:<strings>
<string id="30100">Script to run while saving</string>
<string id="30101">Script to run while restoring</string>
<string id="30102">Run the script</string>
<string id="30103">The temporary folder required to execute the script already exists, please delete it</string>
<string id="30104">The script gave an error</string>
<string id="30105">The script did not gave an error</string>
</strings>

Please, do not hesitate if you have any remarks or comments.


RE: [Release] XBMC Backup - robweber - 2014-11-14

(2014-11-12, 20:22)andisa Wrote: Does XBMC Backup work for anyone with Kodi 14.0 beta1&2?

I've not tested this on Helix yet myself. If you have any feedback in this area please let me know. I did read something about paths needing to end in a slash when using the xbmcvfs.exists() function in Helix but haven't tested that yet.

(2014-11-13, 21:02)jenoyend Wrote: Hello, I succeed in what I wanted to do, run a script during the backup and the restore part.

I had an issue because the script were on my Hard drive.
Even with a chmod 777, I was not able to run it.
So I first copy the script in a temp folder, then run it and delete the temp folder.
I succeed to run a shell script but not a python script.


Glad you were able to get everything working to your satisfaction. I did have a few comments/questions:

1) If you want a temp directory you can use the special://temp directory, this is where xbmc would normally put temporary files. You can use xbmc.translatePath('special://temp') to get it's exact location on each system.
2) Not that it matters much but by using the xbmcvfs instead of shutil and os classes you'd probably get some better cross-platform support. If you're just running this on a few local boxes it probably isn't a big deal.
3) Why the many dialog prompts? If the user has already setup the scripts to run in the settings is it worth sitting on an OK dialog until someone hits a button to run it? I'm just thinking of instances where you might schedule a backup and there isn't someone sitting at the screen to hit the OK prompts. The system might sit there waiting for hours/days.
4) If you want to run a python script this is doable, but you need to pass some other parameters to the subprocess function. If you know the python binary is in the system path you could do subprocess.call(["python",temp_script_path], shell=True) - this would call >python path_top_file.py at a command prompt. You'd probably want some additional logic to test the extension of the script to know if it needed to be launched as a batch/shell script or a python file. I suppose you could also just write a batch file that calls "python file.py" as well.


RE: [Release] XBMC Backup - spager - 2014-11-15

Hi Rob;

The Back up did not work for me. Could be because I have an advanced setting xml. Would it be easier for me to copy files/folders to a msd card from my original identical box and transfer them to the new box? If so which folders do I bring over.
[/quote]

You should be able to do a backup/restore of the advanced settings file. During a restore the addon will even prompt you to restart to make sure your advanced settings take place. If it's easier for you to do a manual file copy I would copy everything in the userdata folder of your first install and copy that to your second. If you want your addons grab that folder as well. Depending on your platform these will be in different places. Here is the wiki page with that info: http://kodi.wiki/view/Userdata
[/quote]

Hi Rob;

Thanks for the Help again Your expertise was right on. Copying the userdata and addon folders made a clone. I am curios if you have thought about doing an addon that simply copies and over writes these two folders. Would solve the gui settings issue for those who are just cloning.


RE: [Release] XBMC Backup - andisa - 2014-11-15

(2014-11-14, 20:48)robweber Wrote:
(2014-11-12, 20:22)andisa Wrote: Does XBMC Backup work for anyone with Kodi 14.0 beta1&2?

I've not tested this on Helix yet myself. If you have any feedback in this area please let me know. I did read something about paths needing to end in a slash when using the xbmcvfs.exists() function in Helix but haven't tested that yet.

I backed up XBMC 12.3 on Win XP before wiping the disk and installing win 7 Pro 64bit. I then installed Kodi 14.0 beta1.
Tried to restore the backup but that didn't work. Well, it restored the gui settings but not the thumbnails and database.

Tried to backup the new system but that doesn't work either. The backup only takes a second or two and the "Thumbnails" folder, "Database" folder and the "library" folder are all empty ("library" folder didn't exist in the XBMC 12.3 backup). To the best of my knowledge the other files appear to be correct.

Updated to beta 2 when it was released but nothing changed.


RE: [Release] XBMC Backup - McButton - 2014-11-16

You posted this systemctl stop xbmc.service. When does that get used?

3. Type touch /var/lock/xbmc.disabled and then press enter <--- OK
4. Type killall -9 xbmc.bin and then press enter - Your media center machine should now go blank <-- OK (resets in about 2 seconds back to the main screen)
5. Connect to your machine using WinSCP and copy the guisettings.xml file to the userdata folder (this is the guisettings.xml file from your backup) <-- OK
6. go back to your putty window and type rm /var/lock/xbmc.disabled <--OK (what does that do?)

If I reset my machine. Nothing happens. SOMETIMES, if I'm fast enough, it'll work. Sometimes, I've put in the systemctl stop in, and hard reset it, and that works. But all methods take like 40 tries. Ideas?

systemctl start xbmc.service just turns it back on. no idea.No matter when in the process I move the file, it rarely sticks.

Nevermind. I wiped my system and started dragging the guisettings before restoring from xbmc backup. Silly...

May want to tweek the tutorial a little, but all works well.


RE: [Release] XBMC Backup - McButton - 2014-11-16

Also, thanks for the assists. With work like yours, hopefully everything becomes easier and more efficient for all of us.


RE: [Release] XBMC Backup - jenoyend - 2014-11-16

(2014-11-14, 20:48)robweber Wrote: Glad you were able to get everything working to your satisfaction. I did have a few comments/questions:

1) If you want a temp directory you can use the special://temp directory, this is where xbmc would normally put temporary files. You can use xbmc.translatePath('special://temp') to get it's exact location on each system.
2) Not that it matters much but by using the xbmcvfs instead of shutil and os classes you'd probably get some better cross-platform support. If you're just running this on a few local boxes it probably isn't a big deal.
3) Why the many dialog prompts? If the user has already setup the scripts to run in the settings is it worth sitting on an OK dialog until someone hits a button to run it? I'm just thinking of instances where you might schedule a backup and there isn't someone sitting at the screen to hit the OK prompts. The system might sit there waiting for hours/days.
4) If you want to run a python script this is doable, but you need to pass some other parameters to the subprocess function. If you know the python binary is in the system path you could do subprocess.call(["python",temp_script_path], shell=True) - this would call >python path_top_file.py at a command prompt. You'd probably want some additional logic to test the extension of the script to know if it needed to be launched as a batch/shell script or a python file. I suppose you could also just write a batch file that calls "python file.py" as well.

Hello, I thank you so much for your help.

I see there is this function:
xbmc.executescript('special://home/scripts/update.py')
so I will use it to do my modification usable to others people if they want to use it. It will then only run python script.

Do you know if there are some xbmc function able to do this:
os.path.basename
os.path.join

At worst I can still manipulate string. It would allow me to not import anymore os shutil and subprocess. Blush

Edit:
With this function: xbmcvfs.copy(source, destination) if the file already exits at destination place, will it overwrite it?

I would like to import xbmc and xbmccvfs when I use putty to test some functions. How can I do it?

Thanks for the support.


RE: [Release] XBMC Backup - 03397 - 2014-11-18

I am using XBMC Backup on gotham 13.2 and I am getting unsuccesful results

19:38:01 T:884 NOTICE: script.xbmcbackup-0.5.8.7: Starting
19:38:01 T:884 NOTICE: script.xbmcbackup-0.5.8.7: Local Dir: C:/Users/nicolas/AppData/Roaming/XBMC/
19:38:01 T:884 NOTICE: script.xbmcbackup-0.5.8.7: Remote Dir: 201411181938/
19:38:01 T:884 NOTICE: script.xbmcbackup-0.5.8.7: Mode - Backup
19:38:01 T:884 NOTICE: script.xbmcbackup-0.5.8.7: Creating Files List
19:38:06 T:884 NOTICE: script.xbmcbackup-0.5.8.7: Writing files to: 201411181938/
19:38:06 T:884 NOTICE: script.xbmcbackup-0.5.8.7: Source: C:/Users/nicolas/AppData/Roaming/XBMC/
19:40:44 T:884 NOTICE: script.xbmcbackup-0.5.8.7: Writing files to: 201411181938/custom_31ced47c/
19:40:44 T:884 NOTICE: script.xbmcbackup-0.5.8.7: Source: C:/Users/nicolas/AppData/Roaming/XBMC/
19:40:55 T:884 ERROR: EXCEPTION: Unknown exception thrown from the call "read"
19:40:55 T:884 ERROR: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
- NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
Error Type: <type 'exceptions.RuntimeError'>
Error Contents: Unknown exception thrown from the call "read"
Traceback (most recent call last):
File "C:\Users\nicolas\AppData\Roaming\XBMC\addons\script.xbmcbackup\default.py", line 69, in <module>
backup.run(mode)
File "C:\Users\nicolas\AppData\Roaming\XBMC\addons\script.xbmcbackup\resources\lib\backup.py", line 248, in run
filesCopied = self.backupFiles(fileGroup['files'],self.xbmc_vfs,self.remote_vfs)
File "C:\Users\nicolas\AppData\Roaming\XBMC\addons\script.xbmcbackup\resources\lib\backup.py", line 461, in backupFiles
wroteFile = dest.put(aFile,dest.root_path + aFile[len(source.root_path):])
File "C:\Users\nicolas\AppData\Roaming\XBMC\addons\script.xbmcbackup\resources\lib\vfs.py", line 100, in put
self.zip.writestr(utils.encode(dest),aFile.read(),compress_type=zipfile.ZIP_DEFLATED)
RuntimeError: Unknown exception thrown from the call "read"
-->End of Python script error report<--

This used to work but not anymore. I am making the backup to a network drive.