Skip to main content
Solved

Download all scripts stored in the JSS

  • June 1, 2015
  • 17 replies
  • 62 views

Forum|alt.badge.img+26

Is there a process for downloading or copying all scripts that are stored in the JSS?

I am creating a new JSS from scratch to be used for testing. Is there a documented way of downloading all of the scripts from a JSS and then importing to another JSS?

Also, I would like to backup just the scripts on a regular basis outside of the typical JSS database backup.

Best answer by m_entholzner

Another simple way: use Casper Admin to create a local repository and all scripts will be there :)

17 replies

Forum|alt.badge.img+17
  • Honored Contributor
  • 1143 replies
  • June 1, 2015

I'm curious about this too. I haven't hit the migrate button yet so my scripts are still in a folder on our dist points. I like that I can see my scripts in a folder and I do back them up occasionally manually.


davidacland
Forum|alt.badge.img+18
  • Valued Contributor
  • 1811 replies
  • June 1, 2015

The REST API will give you the script contents. It downloads in XML format, wrapped in <script_contents> </script_contents> tags.

Not as easy as a copy from the distribution point, but not too horrible.


Forum|alt.badge.img+26
  • Author
  • Honored Contributor
  • 457 replies
  • June 1, 2015

I vaguely recall seeing a script posted on someone's github that might have used the REST API. At least I think it did download all of the scripts. At the time I didn't understand it's value. Of course, now when I need it, I am not able to locate.


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • June 1, 2015

You could probably use this script I created awhile ago as the basis for one that would download all scripts:
https://github.com/mm2270/UpdateExtensionAttributes/blob/master/download-extension-attributes.sh

It was designed to pull down Extension Attribute scripts via the API, but the concept is the same, so it can be adapted I think.


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • June 1, 2015

So I saved you the trouble of reworking my existing 'download EA scripts' script. Here is a version that will download all the regular scripts from your JSS. I had to remove the last section from the original script, which ran each one to check to make sure they exited successfully. This made sense when working with EA scripts, but I realized pretty quickly this was problematic for regular scripts, since those scripts may have GUI elements pop up, or install software updates or even reboot the Mac! Def don't want to run each one on your host system. :)

Anyway, here is the revised version. Run it like:
Moved to my githup page. Find the script here:
https://github.com/mm2270/CasperSuiteScripts/blob/master/download_jss_scripts.sh


Forum|alt.badge.img+26
  • Author
  • Honored Contributor
  • 457 replies
  • June 1, 2015

Thanks for the responses. I'll try out @mm2270's script and followup if it works or not.


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • June 1, 2015

@jhalvorson you may want to wait on using the script. I found a few minor issues with the version I posted here. I'll post an updated one either here or on my github page a little later that works more reliably.


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • June 2, 2015

I added the 'final' version of the script to my github page, so you can grab it from there (see post above for the link)

Although I don't normally do this, I removed the one I had posted above just to prevent anyone from downloading an older version that had a few issues that needed to be tweaked. Best to just grab the one from the JSS. If I make any changes to it they'll be reflected there.


Forum|alt.badge.img+16
  • Honored Contributor
  • 224 replies
  • Answer
  • June 8, 2015

Another simple way: use Casper Admin to create a local repository and all scripts will be there :)


davidacland
Forum|alt.badge.img+18
  • Valued Contributor
  • 1811 replies
  • June 8, 2015

@m.entholzner good to know. Do you have to replicate the DP to the local drive to get them? Does it still copy them if the scripts are stored in the database?


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • June 8, 2015

Hmm, that's actually a very good question re: does it copy them if the scripts are only stored within the db. I have a feeling it may not since there are no physical files to replicate to another DP if so.


Forum|alt.badge.img+16
  • Honored Contributor
  • 224 replies
  • June 9, 2015

@davidacland: yes, the DP replication will get all files from the fileshare as well as the scripts stored in the database.


davidacland
Forum|alt.badge.img+18
  • Valued Contributor
  • 1811 replies
  • June 9, 2015

@m.entholzner thanks for the confirmation, definitely good to know!


Forum|alt.badge.img+26
  • Author
  • Honored Contributor
  • 457 replies
  • June 10, 2015

@m.entholzner is correct. Using Casper Admin and then dragging a local folder into the lower right allows for local syncing of all Packages and Scripts. It does copy down all of the scripts that are stored in the JSS Database.

Unfortunately, it required me to wait for all 187GB of packages to verify that the scripts are copied down too. :)

@mm2270 I'll will try out your script soon! I'll mark your post as an answer once I verify the script works.


mm2270
Forum|alt.badge.img+24
  • Legendary Contributor
  • 7886 replies
  • June 10, 2015

Well, that's definitely good information to know that a replication also pulls down scripts from the db. I didn't think it would do that honestly since they are not really in the "share" as physical files.
Kind of a bummer that it needs to pull down all the packages as well though. It would be nice if it was possible to do a selective replication, or is there a way? I don't do local repository syncs, so I'm not sure.


Forum|alt.badge.img+11
  • Valued Contributor
  • 133 replies
  • January 14, 2016
Using Casper Admin and then dragging a local folder into the lower right allows for local syncing of all Packages and Scripts.

This worked great for me as well. However, I did want to note that in my case I had to drag the folder to the lower left hand of Casper Admin.


Punit_Mac
Forum|alt.badge.img+3
  • New Contributor
  • 1 reply
  • January 9, 2023

So I saved you the trouble of reworking my existing 'download EA scripts' script. Here is a version that will download all the regular scripts from your JSS. I had to remove the last section from the original script, which ran each one to check to make sure they exited successfully. This made sense when working with EA scripts, but I realized pretty quickly this was problematic for regular scripts, since those scripts may have GUI elements pop up, or install software updates or even reboot the Mac! Def don't want to run each one on your host system. :)

Anyway, here is the revised version. Run it like:
Moved to my githup page. Find the script here:
https://github.com/mm2270/CasperSuiteScripts/blob/master/download_jss_scripts.sh


@mm2270earlier i was able to get the script from jss but now im not able to get the scripts from jss can you help me on this.