[ATV] backup & restore scripts
#1
I hacked up some simple backup, getsvn download, and restore shell scripts for the ATV, I've tested them on my atv they work fine but of course I assume no liability if your atv blows up or anything else unexpected happens.

only one backup is maintained, any previous backup is removed before creating the new one.

when restoring, the old/bad build is removed and the backup is copied to the applicable folders. Also, make sure xbmc isn't running of course.

copy/create both scripts in the frontrow folder
make them both executable
create a backup folder "XBMC.bak" in the frontrow folder. If you don't create the XBMC.bak folder then nothing is backed up.

to run them, simply ssh and execute:
./backup.sh
./getsvn.sh 23524
./installtgz.sh XBMC_OSX_23524.tgz
./restore.sh

substitute the build# and filename as applicable, you can use any builld# available @ http://sshcs.com/xbmc/?mode=BO

./backup.sh
Code:
#!/bin/sh

  PW="frontrow"

  # backup existing settings and app if .bak folder exist
  if [ -d /Users/frontrow/XBMC.bak ]; then
    echo "Backup folder found, removing any existing backup"
    echo $PW | sudo -S rm -r /Users/frontrow/XBMC.bak/*
    echo "Backing up XBMC.app folder this might take a few minutes"
    cp -r /Users/frontrow/Applications/XBMC.app /Users/frontrow/XBMC.bak/XBMC.app
    echo "Backing up application support/xbmc folder this might take a few minutes"
    cp -r "/Users/frontrow/Library/Application Support/XBMC" "/Users/frontrow/XBMC.bak/XBMC"
    echo "Backup finished"
  fi

./getsvn.sh
Code:
#!/bin/sh

BUILD=$1

if [ ! $BUILD = "" ]; then

  if [ ! -e "installtgz.sh" ]; then
    echo "downloading update sshcs script to installtgz.sh"
    wget "http://files.getdropbox.com/u/858897/XBMC/xbmc-9.04_update_sshcs.sh"
    mv xbmc-9.04_update_sshcs.sh installtgz.sh
    chmod +x installtgz.sh
  fi
  
  echo "Downloading OSX build $BUILD..."
  wget "http://www.sshcs.com/xbmc/inc/EVA.asp?mode=NDLC&FN=OSX&BN=$BUILD"
  echo "If the download completed successfully,"
  echo "To install execute ./installtgz.sh and the filename of the tgz file"
  echo "make sure XBMC is NOT running of course, and you may want to backup your existing first"

else
  echo "No build# included, please try again with a valid build#"
  
fi

./installtgz.sh is simply xbmc-9.04_update_sshcs.sh renamed (its autodownloaded if needed by getsvn.sh)


./restore.sh
Code:
#!/bin/sh

  PW="frontrow"

  # restore existing settings and app if .bak folder exist
  if [ -d /Users/frontrow/XBMC.bak/XBMC.app ]; then
    echo "Backup app folder found, removing current XBMC.app"
    echo $PW | sudo -S rm -r /Users/frontrow/Applications/XBMC.app
    echo "Restoring backup XBMC.app to Applications/XBMC.app"
    cp -r /Users/frontrow/XBMC.bak/XBMC.app /Users/frontrow/Applications/XBMC.app
    echo "app restore finished"
  fi
  
  if [ -d /Users/frontrow/XBMC.bak/XBMC ]; then
    echo "Backup user folder found, removing current settings"
    echo $PW | sudo -S rm -r "/Users/frontrow/Library/Application Support/XBMC"
    echo "Restoring backup settings to Application Support"
    cp -r "/Users/frontrow/XBMC.bak/XBMC" "/Users/frontrow/Library/Application Support/XBMC"
    echo "settings retore finished"
  fi
Reply
#2
hi,

this is very helpful, Thanks!

I wanted to ask you, is it possible to make it backup different versions in version number folders?.

-- XBMC.bak
-- r22240
[INDENT]-- XBMC
[/INDENT]
[INDENT]-- XBMC.app
[/INDENT]
-- r22528
[INDENT]-- XBMC
[/INDENT]
[INDENT]-- XBMC.app
[/INDENT]

we can then restore the specific version(./restore.sh r22240).Version info can be obtained from "/Volumes/frontrow/Applications/XBMC.app/Contents/Info.plist"

Thanks
Zeljko
Reply
#3
Hey TeknoJnky,

nice work!
you might want to combine those backup scripts with the ability to install the backups in Launcher. If you need hints or have any questions, please feel free to ask.

First thing could be to add a (dummy) download location to the plist that points to a local one (via defaults write com.teamxbmc.xbmclauncher XBMCAdditionalDownloadPlistURLs). That plist is has no download (or maybe a dummy), but just runs your restore script.

Next might be automatic backup on install. This could be done by wrapping the sshcs installer script and additionally call your backup script.

Again, if there are any problems, feel free to ask.

HTH,
mdd

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules. If you don't have the time to read them, please don't take the time to post in this forum!
For troubleshooting and bug reporting please make sure you read this first.
Reply
#4
I'm sure its possible, but there are some issues that would have to be worked out like, how would the script be able to automatically determine what exact build was active in order to create the revision subfolders for one.

Ideally, I'd love a script that functions like the t3ch upgrader, allowing for multiple builds to be installed and letting you switch between them at will, but I don't have the unix scripting knowledge/knowhow to make something that complex.

I will be adding a couple more scripts to make it easier to make the whole process easier to:

backup the current build (done)
download any specific svn (from any available at sshcs)
install any specific svn that was downloaded
restore backup build (done)

I also welcome any suggestions/improvements/etc.

edit:
thanks mdd

eventually I'd like to have something available/working from the launcher

but I think the biggest problem is I would have to figure out how to interface with the plists and launcher to/from the script(s).

I know vbscript somewhat well, but shell scripting is something entirely new for me.
Reply
#5
TeknoJnky Wrote:I'm sure its possible, but there are some issues that would have to be worked out like, how would the script be able to automatically determine what exact build was active in order to create the revision subfolders for one.

Ideally, I'd love a script that functions like the t3ch upgrader, allowing for multiple builds to be installed and letting you switch between them at will, but I don't have the unix scripting knowledge/knowhow to make something that complex.

I will be adding a couple more scripts to make it easier to make the whole process easier to:

backup the current build (done)
download any specific svn (from any available at sshcs)
install any specific svn that was downloaded
restore backup build (done)

I also welcome any suggestions/improvements/etc.

edit:
thanks mdd

eventually I'd like to have something available/working from the launcher

but I think the biggest problem is I would have to figure out how to interface with the plists and launcher to/from the script(s).

I know vbscript somewhat well, but shell scripting is something entirely new for me.

I am not too sure how to do it, but I am sure it can be done. you can get the version number from /Volumes/frontrow/Applications/XBMC.app/Contents/Info.plist

as for the switching between the builds you could do it by creating the symbolic link to the revision e.g. ln -s /Users/frontrow/XBMC.bak/XBMC.app Applications/XBMC.app

Zeljko
Reply
#6
yea I am doing something like now manually for the applications folder, I keep a working build @ Applications/XBMC.working and then symlink XBMC.app to it, so right now the existing sshcs downloaded overwrites the XBMC.app, I go after and manually mv it to XBMC.build# then do the XBMC.app symlink.

If I were to emulate the t3ch upgrader script, I would do exactly that (have a designated svn folder, with symlinks to the active .app and XBMC folders).
Reply
#7
TeknoJnky Wrote:[...]but I think the biggest problem is I would have to figure out how to interface with the plists and launcher to/from the script(s).

In a first try, I'd just add 2 "downloads", that simply call your 2 scripts. Should be as simple as this plist:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
    <dict>
        <key>UpdateScript</key>
        <string>file:///Users/frontrow/backup.sh</string>
        <key>URL</key>
        <string>file:///Users/frontrow/backup.sh </string>
        <key>Type</key>
        <string>Script</string>
        <key>Name</key>
        <string>Backup current XBMC</string>
    </dict>
    <dict>
        <key>UpdateScript</key>
        <string>file:///Users/frontrow/restore.sh</string>
        <key>URL</key>
        <string>file:///Users/frontrow/restore.sh </string>
        <key>Type</key>
        <string>Script</string>
        <key>Name</key>
        <string>Restore last XBMC backup</string>
    </dict>
</array>

This is untested, but *should* work somehow like that. I think the URL needs to be provided, so just give Launcher something. Hopefully "downloading" the script should also from a file:// URL.

Let me know if there are any problems.
Second step could be to dynamically modify that plist once a new backup was done, so it appears in the downloads list.

cheers,
mdd

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules. If you don't have the time to read them, please don't take the time to post in this forum!
For troubleshooting and bug reporting please make sure you read this first.
Reply
#8
A teaser for what I'll put shortly...


Quote:login as: frontrow
Welcome to the AppleTV (via atv-usbcreator)
frontrow@appletv.'s password:
-bash-2.05b$ ./backup.sh
Backup folder found, removing any existing backup
Password:
Backing up XBMC.app folder
Backing up application support/xbmc folder
Backup finished
-bash-2.05b$ ./getsvn.sh 23524
Downloading OSX build 23524...
--19:46:20-- http://www.sshcs.com/xbmc/inc/EVA.asp?mo...X&BN=23524
=> `EVA.asp?mode=NDLC&FN=OSX&BN=23524'
Resolving http://www.sshcs.com... 72.167.131.44
Connecting to http://www.sshcs.com|72.167.131.44|:80... connected.
HTTP request sent, awaiting response... 302 Object moved
Location: /xbmc/binaries/Builds/XBMC_OSX_23524.tgz [following]
--19:46:22-- http://www.sshcs.com/xbmc/binaries/Build..._23524.tgz
=> `XBMC_OSX_23524.tgz'
Reusing existing connection to http://www.sshcs.com:80.
HTTP request sent, awaiting response... 200 OK
Length: 46,907,906 (45M) [application/x-compressed]

100%[====================================>] 46,907,906 227.89K/s ETA 00:00

19:50:08 (203.49 KB/s) - `XBMC_OSX_23524.tgz' saved [46907906/46907906]

If the download completed successfully,
To install execute ./installtgz.sh and the filename of the tgz file
make sure XBMC is NOT running of course, and you may want to backup your existin g first
-bash-2.05b$ ./installtgz.sh XBMC_OSX_23524.tgz
Extracting download XBMC_OSX_23524.tgz
Installing from diskimage /Users/frontrow/Library/Caches/XBMCLauncherDownloads/X BMC.dmg
Password:
Checksumming Driver Descriptor Map (DDM : 0)...
Driver Descriptor Map (DDM : 0): verified CRC32 $143CFD51
Checksumming Apple (Apple_partition_map : 1)...
Apple (Apple_partition_map : 1): verified CRC32 $72DE1F96
Checksumming disk image (Apple_HFS : 2)...
..............................................................................
disk image (Apple_HFS : 2): verified CRC32 $B4835F56
Checksumming (Apple_Free : 3)...
(Apple_Free : 3): verified CRC32 $00000000
verified CRC32 $06BE660D
/dev/disk1 Apple_partition_scheme
/dev/disk1s1 Apple_partition_map
/dev/disk1s2 Apple_HFS /Volumes/XBMC
"disk1" unmounted.
"disk1" ejected.
osx_gl_fullscreen present in advancedsettings.xml
-bash-2.05b$
Reply
#9
Thanks for these scripts, they are very helpful.
Reply
#10
Is there anything missing on my machine when it cant execute the command WGET.

i just get a command not found on the lines with wget.

rest of scripts works perfectly, Thanks alot!

UPDATE:

Installed the binutils manually and works.
Great script, worked like a charm!
Thanks!
Reply
#11
Nice sripts - but I get this output:
bad interpreter: No such file or directory

I'm a Windows user.
Searched for the error and tried different solutions, but none of them worked for me.

Most likely it is an editor problem...? I have also tried WinVI with the same result.

Please tell me how to get this work Wink
Vero 4k+ | OSMC Kodi 19.1
Sony KD-65A1
Reply
#12
Bobby Blixberg Wrote:Nice sripts - but I get this output:
bad interpreter: No such file or directory

I'm a Windows user.
Searched for the error and tried different solutions, but none of them worked for me.

Most likely it is an editor problem...? I have also tried WinVI with the same result.

Please tell me how to get this work Wink

Do you have nano on your ATV? It's a must have! Then you can SSH in and create/edit scripts in a terninal window irregardless of your computer's OS.

Try SSHing in and issuing:

nano test

you should be launched into the editor and it will create automatically a new file called test. ctrl-x allows you to exit and prompts for save y/n. Pretty straightforward..

Jim
Reply
#13
Great - it works. Thank you very much, Jimmer!
Vero 4k+ | OSMC Kodi 19.1
Sony KD-65A1
Reply
#14
can i download from the official nightlies from mirrors.xbmc.org/nightlies/osx/ ?
Reply
#15
Scripts work great! Thanks for the effort, TeknoJnky.
Reply

Logout Mark Read Team Forum Stats Members Help
[ATV] backup & restore scripts0