Download all scripts stored in the JSS

jhalvorson
Valued Contributor

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.

1 ACCEPTED SOLUTION

m_entholzner
Contributor III
Contributor III

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

View solution in original post

16 REPLIES 16

CasperSally
Valued Contributor II

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
Honored Contributor II
Honored Contributor II

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.

jhalvorson
Valued Contributor

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
Legendary Contributor III

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
Legendary Contributor III

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

jhalvorson
Valued Contributor

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

mm2270
Legendary Contributor III

@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
Legendary Contributor III

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.

m_entholzner
Contributor III
Contributor III

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

davidacland
Honored Contributor II
Honored Contributor II

@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
Legendary Contributor III

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.

m_entholzner
Contributor III
Contributor III

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

davidacland
Honored Contributor II
Honored Contributor II

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

jhalvorson
Valued Contributor

@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
Legendary Contributor III

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.

FritzsCorner
Contributor III
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.

1715231df43a40b19b4598f6fa159bdc